[Python-bugs-list] [ python-Bugs-693121 ] Set == non-Set is a TypeError
SourceForge.net
noreply@sourceforge.net
Tue, 25 Feb 2003 11:37:45 -0800
Bugs item #693121, was opened at 2003-02-25 14:37
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=693121&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Chris Reedy (creedy)
Assigned to: Nobody/Anonymous (nobody)
Summary: Set == non-Set is a TypeError
Initial Comment:
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.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=693121&group_id=5470