On 28/10/2012 23:51, Mark L. Hotz wrote:
I have what I think should be a relatively simple question for someone who
is knowledgeable about Python.
Sorry you've come to the wrong place :)
At the IDLE prompt, when I enter "b" > 99, it responds True. In fact, it
doesn't matter which number is entered here, "b" is always greater (e.g. "b"
1 == True; "b" > 100000 == True, or "b" < 99 = False).
Why is this true? If I use ord("b") it returns 98, so Python cannot be
using the ASCII or Unicode value when interpreting "b" > 99. When I sort a
mixed list using Python, and the list contains "b" among a series of numeric
values, "b" is always sorted as last, indicating that it has a value greater
than the highest number?
How do I prove that "b" is greater than any number? Or is it something very
simple, and Python simply orders characters after numbers, or perhaps Python
only interprets numbers like 99 as a 9 (i.e. ord("9") == 57)?
Thank you.
The behaviour of Python between version 2 and 3 has been changed hence.
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 'b' > 99
True
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 'b' > 99
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unorderable types: str() > int()
--
Cheers.
Mark Lawrence.
--
http://mail.python.org/mailman/listinfo/python-list