17 May 06:29
Re: datetime syntax error for May 8th and 9th 2008??
From: John Fouhy <john <at> fouhy.net>
Subject: Re: datetime syntax error for May 8th and 9th 2008??
Newsgroups: gmane.comp.python.tutor
Date: 2008-05-17 04:29:50 GMT
Subject: Re: datetime syntax error for May 8th and 9th 2008??
Newsgroups: gmane.comp.python.tutor
Date: 2008-05-17 04:29:50 GMT
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
RSS Feed