comparing str's with ints
Frank Tobin
ftobin at neverending.org
Mon Apr 29 15:40:00 EDT 2002
Frank Tobin, on 2002-04-29, wrote:
> BUT, *this* does not make sense:
> >>> '5' > 3
> 1
>
> What in the world is supposed to be the semantics of comparing a string
> with an integer? Seems like a type trap...
I just read the Python language spec:
The operators <, >, ==, >=, <=, and != compare the values of two
objects. The objects need not have the same type. If both are numbers,
they are converted to a common type. Otherwise, objects of different
types always compare unequal, and are ordered consistently but
arbitrarily.
'arbitrarily'. Lovely, eh?
--
Frank Tobin http://www.neverending.org/~ftobin/
More information about the Python-list
mailing list