diff options
author | Guido van Rossum <guido@python.org> | 2003-01-14 16:45:04 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2003-01-14 16:45:04 (GMT) |
commit | 50e92235e7fc7151f591f76b73fb539e34593405 (patch) | |
tree | e1c2d1d60af81a1883735afe670e760b87e7a7a6 /Lib/sets.py | |
parent | 8bb90a59a641979385f063249143a05a6198725e (diff) | |
download | cpython-50e92235e7fc7151f591f76b73fb539e34593405.zip cpython-50e92235e7fc7151f591f76b73fb539e34593405.tar.gz cpython-50e92235e7fc7151f591f76b73fb539e34593405.tar.bz2 |
Explicitly raise an exception in __cmp__ -- this clarifies that cmp()
is not supported on sets. (Unfortunately, sorting a list of sets may
still return random results because it uses < exclusively, but for
sets that inly implements a partial ordering. Oh well.)
Diffstat (limited to 'Lib/sets.py')
-rw-r--r-- | Lib/sets.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/sets.py b/Lib/sets.py index 2605c98..6d2c032 100644 --- a/Lib/sets.py +++ b/Lib/sets.py @@ -102,6 +102,11 @@ class BaseSet(object): """ return self._data.iterkeys() + # Three-way comparison is not supported + + def __cmp__(self, other): + raise TypeError, "can't compare sets using cmp()" + # Equality comparisons using the underlying dicts def __eq__(self, other): |