08 and 09 in sequence create "invalid token" error?!

I

IamIan

Hello all,

I am confused as to why including 08 or 09 in a sequence (list or
tuple) causes this error. All other numbers with a leading zero work.

[01,02,03,04,05,06,07] is fine
[01,02,03,04,05,06,07,10] is fine

[01,02,03,04,05,06,08] produces "SyntaxError: invalid token", as
does: [01,02,03,04,05,06,09]

I have tried this both in a script and in the interactive interpreter.
Using Python 2.3.4

Thanks!
 
?

=?ISO-8859-2?Q?Wojciech_Mu=B3a?=

IamIan said:
I am confused as to why including 08 or 09 in a sequence (list or
tuple) causes this error. All other numbers with a leading zero work.

All literals that start with "0" digit are considered as
octal numbers, i.e. only digits "0".."7" are allowed.

See octinteger lexical definition:
http://docs.python.org/ref/integers.html

w.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top