Message14833
Comparing Sets to non-Sets results in a TypeError. For
example:
>>> from sets import Set
>>> x = Set([1])
>>> x == 2
TypeError: Binary operation only permitted between sets
This seems to be inconsistent with other Python
behavior. For example:
>>> (1,2,3) == 2
0
>>> "abcd" == 2
0
Assuming that the standard behavior is what is desired,
the implementation of __eq__ and other comparison
operators in sets.py should be changed to return
NotImplemented when the other object is not a Set.
Note: Looking at the code, I'm not sure whether the
implementation of __lt__, __le__, etc. should also be
changed to not return a Type Error.
|
|
| Date |
User |
Action |
Args |
| 2007-08-23 14:11:27 | admin | link | issue693121 messages |
| 2007-08-23 14:11:27 | admin | create | |
|