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.

Author terry.reedy
Recipients chris.jerdonek, cvrebert, docs@python, ezio.melotti, mark.dickinson, mikehoy, rhettinger, terry.reedy
Date 2012-09-22.21:01:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1348347717.78.0.377914197908.issue12067@psf.upfronthosting.co.za>
In-reply-to
Content
You are right, I did not look deep enough. I was fooled by the conversion of NotImplemented, returned from object.__le__, etc, to TypeError. Sorry for that noise.

For comparison and arithmetic, the actual alternative to defining a function that returns NotImplemented seems to be to not define it at all.

class C():
    def __ge__(self, other):
        return True
    def __add__(self, other):
        return 44
    __radd__ = __add__

class O():
    pass  # removed NotImplemented defs
    
c = C()
o = O()
print(c >= o, o <= c)
# True True
print(c + o, o + c)
# 44 44

(I looked at the codes for binary_op1 in abstract.c and do_richcompare in object.c and do not yet see any effective difference between not defined and a NotImplemented return.)

I'll take a look at the patch later.
History
Date User Action Args
2012-09-22 21:01:57terry.reedysetrecipients: + terry.reedy, rhettinger, mark.dickinson, ezio.melotti, cvrebert, chris.jerdonek, docs@python, mikehoy
2012-09-22 21:01:57terry.reedysetmessageid: <1348347717.78.0.377914197908.issue12067@psf.upfronthosting.co.za>
2012-09-22 21:01:57terry.reedylinkissue12067 messages
2012-09-22 21:01:56terry.reedycreate