On 28/07/13 05:04, Steven D'Aprano wrote:
On 28/07/13 09:53, Alan Gauld wrote:

Its not that false propagates out, it's how Python does a comparison
...
comparison operations return -1, 0 or 1.

You're thinking of the cmp() builtin

I was trying to use that for simplicity. (Although given Jim's penchant for understanding the inner workings, that was probably a mistake!)

The real point I was trying to make was that the equality test does not work by comparing the boolean value of the expressions on each side but by applying comparisons to the actual values (so for lists it checks length and item values). By overloading the comparison operators the test rules are effectively arbitrary for any given class. The boolean result is then applied at the very end based on the test outcome.

Comparison operators haven't depended on cmp() for a long time. You can
google "rich comparison operators" for more info:

https://duckduckgo.com/?q=rich%20comparison%20operators

I only read the first two but one question remains:
If cmp() is gone is __cmp__() still supported? I'm assuming it
must be for backward compatibility?


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to