Commit f9918f75 authored by Tim Peters's avatar Tim Peters

Record a clue about why __or__ is not union, etc.

parent 5e4f58f8
...@@ -141,6 +141,11 @@ class BaseSet(object): ...@@ -141,6 +141,11 @@ class BaseSet(object):
# Standard set operations: union, intersection, both differences. # Standard set operations: union, intersection, both differences.
# Each has an operator version (e.g. __or__, invoked with |) and a # Each has an operator version (e.g. __or__, invoked with |) and a
# method version (e.g. union). # 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): def __or__(self, other):
"""Return the union of two sets as a new set. """Return the union of two sets as a new set.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment