How to subclass a built-in int type and prevent comparisons
Terry Reedy
tjreedy at udel.edu
Fri Feb 29 16:09:36 EST 2008
"Bronner, Gregory" <gregory.bronner at lehman.com> wrote in message
news:21CFA1FC32D3214EBFA2F449FF211E310EAD2948 at nypcmg1exms318.leh.lbcorp.lehman.com...
| The native implementation of int goes to great lengths to allow
| illogical comparisons such as the one below.
| >>> import xml as x
| >>> x
| >>> <module 'xml' from 'c:\python25\lib\xml\__init__.pyc'>
|
| >>> x>4
| True
| >>> x<4
| False
Python once made all objects comparable.
No longer true.
'Illogical' comparisons will raise exceptions in 3.0
but must be maintained in 2.x for back compatibility.
tjr
More information about the Python-list
mailing list