sorting a list numbers stored as strings

ZeD vito.detullio at gmail.com
Tue Sep 25 14:36:21 EDT 2007


thebjorn wrote:

>> >>> int("020")
>> 20
>> >>> 020
>> 16
> 
> You can get the latter behavior using eval:

why using eval when int has the "base" optional parameter?

>>> int("020")
20
>>> int("020", 8)
16
>>> int("09", 8)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 8: '09'
>>>

-- 
Under construction



More information about the Python-list mailing list