Octal number problem

Raymond Hettinger vze4rx4y at verizon.net
Wed Feb 19 21:27:37 EST 2003


[Gary Duncan]
> Python has the quaint behaviour of interpreting
> a numeric string with a leading zero as octal, a bit like C.
>
> How does one disable this behaviour, ie get it to
> treat such strings as a "normal" decimal number ?

The int() function will assume base 10 and ignore the
leading zero cue for octal:

>>> int("0100")
100


Raymond Hettinger







More information about the Python-list mailing list