From: Tim Peters Date: Sun, 25 Aug 2002 17:10:17 +0000 (+0000) Subject: Record a clue about why __or__ is not union, etc. X-Git-Tag: v2.3c1~4299 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4924db176bdd0b4f93bf67c16487f468a1644c1c;p=python Record a clue about why __or__ is not union, etc. --- diff --git a/Lib/sets.py b/Lib/sets.py index d42259108c..ff0ace0fc7 100644 --- a/Lib/sets.py +++ b/Lib/sets.py @@ -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.