]> granicus.if.org Git - python/commitdiff
Record a clue about why __or__ is not union, etc.
authorTim Peters <tim.peters@gmail.com>
Sun, 25 Aug 2002 17:10:17 +0000 (17:10 +0000)
committerTim Peters <tim.peters@gmail.com>
Sun, 25 Aug 2002 17:10:17 +0000 (17:10 +0000)
Lib/sets.py

index d42259108cdb81695ca70d3ce7618c101d942f4d..ff0ace0fc70d2ebbf40a2af34f3449e725605eca 100644 (file)
@@ -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.