eval('07') works, eval('08') fails, why?

Terry Reedy tjreedy at udel.edu
Thu Jan 8 21:04:07 CET 2009

Alex van der Spek wrote:

> I can't think of anything that could cause this. Similarly, eval('09') 
> fails, but for string 0x with x<8 it works. I am teaching myself Python 
> in order to climb the ladder from Algol(1980s)-->Pascal(1990s)--
>> VisualBasic(2000)-->Python. I am a physicist, have programmed computers 
> all my life but I won't understand the real tech jargon of present day 
> computer science. Please keep it simple

I taught myself Python as a statistician with a Fortran/C backgound by 
interleaving interactive experiments (such as you did) with reading of 
the manuals.  The Language Manual chapter on Lexical Analysis has an 
Integer Literals subsection that answers this question.  I strongly 
recommend you peruse the Language Manual and the initial Library Manual 
chapters on built-ins.


More information about the Python-list mailing list