From 4924db176bdd0b4f93bf67c16487f468a1644c1c Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Sun, 25 Aug 2002 17:10:17 +0000 Subject: [PATCH] Record a clue about why __or__ is not union, etc. --- Lib/sets.py | 5 +++++ 1 file changed, 5 insertions(+) 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. -- 2.40.0