Astan Chee a écrit :
> Hi,
> I just tried to do
> eval('00052') and it returned 42.
> Is this a known bug in the eval function? Or have I missed the way eval
> function works?
> Thanks

Ad Erik replied, a literal value beginning by 0 is interpreted as an
octal value (and beginning by 0x it is interpreted as hexadecimal value).

You may use int construction from string, which allow to specify a base
(default to ten):

>>> int('00052')
52
>>> int('00052',10)
52
>>> int('00052',8)
42

Note: this avoid possible evaluation of undesired Python expressions...

A+

Laurent.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to