Movatterモバイル変換


[0]ホーム

URL:


homepage

Message89553

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Authorterry.reedy
Recipientsgeorg.brandl, medwards, rhettinger, terry.reedy
Date2009-06-21.01:29:50
SpamBayes Score3.1225023e-13
Marked as misclassifiedNo
Message-id<1245547792.74.0.686749307577.issue4395@psf.upfronthosting.co.za>
In-reply-to
Content
The situation appears to be at least slightly different from what Guidostated. In 3.x, all classes subclass object, which has .__ne__, so ifthat stopped inferred != behavior, it would never happen.>>> class A:def __eq__(s,p): return 1>>> id(object.__ne__)10703216>>> id(A.__ne__)10703216No new A.__ne__ added.  But>>> c,d=object(),object()>>> c==dFalse>>> c!=dTrue>>> a,b = A(),A()>>> a==b1>>> a!=bFalseSo it seems that a!=b *is* evaluated as not a==b rather than asa.__ne__(b). If so, my revised suggested replacement would be:"There is one implied relationship among comparison operators: defining__eq__ causes '!=' to be evaluated as 'not ==' (but not the other way). There is no similar relationship for the order comparisons."I am a bit puzzled though. Inttp://svn.python.org/view/python/branches/py3k/Python/ceval.c?revision=73066&view=markupI traced compare_op to cmp_outcome to (in object.c) PyOjbect_RichCompareto do_richcompare to class specific tp_richcompare and I do not see thespecial casing of eq. However, I am newbie at codebase.
History
DateUserActionArgs
2009-06-21 01:29:53terry.reedysetrecipients: +terry.reedy,georg.brandl,rhettinger,medwards
2009-06-21 01:29:52terry.reedysetmessageid: <1245547792.74.0.686749307577.issue4395@psf.upfronthosting.co.za>
2009-06-21 01:29:51terry.reedylinkissue4395 messages
2009-06-21 01:29:50terry.reedycreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp