Error evaluating numbers starting in zero
Remco Gerlich
scarblac at pino.selwerd.nl
Mon Dec 18 07:06:01 EST 2000
More information about the Python-list mailing list
Mon Dec 18 07:06:01 EST 2000
- Previous message (by thread): Error evaluating numbers starting in zero
- Next message (by thread): Error evaluating numbers starting in zero
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Mike Brenner <mikeb at mitre.org> 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
- Previous message (by thread): Error evaluating numbers starting in zero
- Next message (by thread): Error evaluating numbers starting in zero
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list