How to convert a "long in a string" to a "long"?

Leif K-Brooks eurleif at ecritters.biz
Fri Nov 18 12:49:50 EST 2005


Sion Arrowsmith wrote:
> Steven Bethard  <steven.bethard at gmail.com> wrote:
> 
>>ondekoza at gmail.com wrote:
>>
>>>s = long("0xffffffffL")
>>>ValueError: invalid literal for long(): 0xffffffffL
>>>
>>>>>int("0xffffffff", 0)
>>
>>4294967295L
> 
> So why does the base argument to int() (or long()) default to
> 10 and not 0?

Because it's designed for numbers normal people provide, not for numbers
programmers provide. Normal people see 0123 as being equal to 123, not 83.



More information about the Python-list mailing list