This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: getattr([], '__eq__')(some-object) is NotImplemented
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: collinwinter, lpd
Priority: normal Keywords:

Created on 2007-06-03 17:10 by lpd, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg32194 - (view) Author: L. Peter Deutsch (lpd) Date: 2007-06-03 17:10
Consider:

a = []

class B: pass

class C(object): pass

print a == B()

print a == C()

m = getattr(a, '__eq__')

print m(B())

print m(C())

I think this should print 'False' 4 times, but it actually prints:

False
False
NotImplemented
NotImplemented

If this isn't a bug, please explain why.
msg32195 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2007-06-05 18:23
This isn't a bug because a.__eq__() isn't the whole story on equivalence testing. NotImplemented is a perfectly valid return value for a comparison method; in this case, it signals the == operator to try a different approach.
History
Date User Action Args
2022-04-11 14:56:24adminsetgithub: 45029
2007-06-03 17:10:25lpdcreate