Octal number problem

Chad Netzer cnetzer at mail.arc.nasa.gov
Wed Feb 19 21:34:23 EST 2003


On Wed, 2003-02-19 at 18:19, Gary Duncan wrote:
> Python has the quaint behaviour of interpreting
> a numeric string with a leading zero as octal, a bit like C.

yes; eval("010") == 8

however,

int("010") = 10

So you can use int() to get the desired behavior.  Depending on your
application, this may or may not be convenient.

-- 
Bay Area Python Interest Group - http://www.baypiggies.net/

Chad Netzer
(any opinion expressed is my own and not NASA's or my employer's)







More information about the Python-list mailing list