mirror of
https://github.com/python/cpython.git
synced 2025-08-28 20:56:54 +00:00
Record a clue about why __or__ is not union, etc.
This commit is contained in:
parent
c8f8034512
commit
4924db176b
1 changed files with 5 additions and 0 deletions
|
@ -141,6 +141,11 @@ class BaseSet(object):
|
|||
# Standard set operations: union, intersection, both differences.
|
||||
# Each has an operator version (e.g. __or__, invoked with |) and a
|
||||
# method version (e.g. union).
|
||||
# Subtle: Each pair requires distinct code so that the outcome is
|
||||
# correct when the type of other isn't suitable. For example, if
|
||||
# we did "union = __or__" instead, then Set().union(3) would return
|
||||
# NotImplemented instead of raising TypeError (albeit that *why* it
|
||||
# raises TypeError as-is is also a bit subtle).
|
||||
|
||||
def __or__(self, other):
|
||||
"""Return the union of two sets as a new set.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue