sorting items in a table problematic because of scientific notation

skip at pobox.com skip at pobox.com
Wed Apr 29 10:39:47 EDT 2009


    >> Maybe string.ato[if] used to behave that way?

    John> Nope.
    ...

OK, I remember what it was.  The C atof()/atoi() functions will stop at the
first non-numeric character.  (I believe the more modern strtod/strtof
functions behave the same way.)  You could thus call

    atof(" 12345 abcdef")

and get back 12345.  That I'm certain is an error in Python.  Somewhere in
my small walnut of a brain I must have conflated that with numeric strings
which contain extraneous whitespace but no other extra characters.

Skip



More information about the Python-list mailing list