Re: How to subclass a built-in int type and prevent comparisons
- From: castironpi@xxxxxxxxx
- Date: Fri, 29 Feb 2008 13:26:32 -0800 (PST)
On Feb 29, 3:09 pm, "Terry Reedy" <tjre...@xxxxxxxx> wrote:
"Bronner, Gregory" <gregory.bron...@xxxxxxxxxx> wrote in message
news:21CFA1FC32D3214EBFA2F449FF211E310EAD2948@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| 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
Tell Wall. But why not [ 2, 3 ]>= 2? Back to your question, another
option is to not subclass.
.
- References:
- Re: How to subclass a built-in int type and prevent comparisons
- From: Terry Reedy
- Re: How to subclass a built-in int type and prevent comparisons
- Prev by Date: Re: How to subclass a built-in int type and prevent comparisons
- Next by Date: Re: convert string number to real number - ValueError: invalid literal for int() with base 10: '"2"'
- Previous by thread: Re: How to subclass a built-in int type and prevent comparisons
- Index(es):