John Fouhy | 17 May 06:29

Re: datetime syntax error for May 8th and 9th 2008??

On 17/05/2008, Che M <pine508 <at> hotmail.com> wrote:
> >>> datetime.datetime(2008, 05, 08)
> SyntaxError: invalid token

It's simpler than that... Try this:

>>> x = 08
  File "<stdin>", line 1
    x = 08
         ^
SyntaxError: invalid token
>>> x = 010
>>> x
8

Basically, python interprets integer literals starting with 0 as octal
numbers.  It's an old convention from C (or earlier?).  It doesn't
affect strings, so int('010') == 10 (unless you use eval).

HTH!

--

-- 
John.
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor


Gmane