Error evaluating numbers starting in zero

Remco Gerlich scarblac at
Mon Dec 18 13:06:01 CET 2000

Mike Brenner <mikeb at> wrote in comp.lang.python:
> >> I have a python checkbook program that evaluates date strings, such
> >> as "01/31/99". Most dates are fine, but if I have a date such as
> >> "01/08/99", python runs into an error when it tries to eval("08").
> > Use int() instead of eval().
> So, that may also explain the failure with 
> 	i = 08
> and with reading in numbers,
> the python interpretor must be using EVAL instead of INT?

No, the failure is that this is a syntax error. In fact, it's the
other way around - eval() uses the python interpreter. That's what eval
does, evaluate an expression like the interpreter does. int() converts
things to integers.

If a number starts with 0, it is in octal and not in decimal. So i = 08 is a
syntax error.

Remco Gerlich

More information about the Python-list mailing list