Ezio Melotti added the comment:
The leading zero is used to define octal numbers, 8 and 9 are not valid
octal digits, see
http://docs.python.org/reference/lexical_analysis.html#integer-and-long-integer-literals
Also, you don't need to use eval to reproduce that behavior.
The number displayed i
Raymond Hettinger added the comment:
They don't crash. They raise a SyntaxError because the "08" and "09"
are invalid octal literals.
If you're working with decimal literals that are padded on the left with
zeroes, those need to be stripped off before conversion:
'000987'.lstrip('0') --> '
New submission from David Nicol :
The single line statements:
eval("08") ; and
eval("09")
both crash; while
eval("07") works fine
--
components: None
messages: 80982
nosy: davidnicol
severity: normal
status: open
title: Error with Eval
type: compile error
versions: Python 2.6
_