Simple Python question for some

Mark L. Hotz mlhotz at gmail.com
Sun Oct 28 19:51:31 EDT 2012


I have what I think should be a relatively simple question for someone who
is knowledgeable about Python.

 

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.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121028/c4c8a350/attachment.html>


More information about the Python-list mailing list