SyntaxError not honoured in list comprehension?

Mark Dickinson dickinsm at gmail.com
Mon Jul 5 03:44:52 EDT 2010


On Jul 4, 11:02 pm, John Machin <sjmac... at lexicon.net> wrote:
> On Jul 5, 1:08 am, Thomas Jollans <tho... at jollans.com> wrote:
>
> > On 07/04/2010 03:49 PM, jmfauth wrote:
> > >   File "<psi last command>", line 1
> > >     print9.0
> > >            ^
> > > SyntaxError: invalid syntax
>
> > somewhat strange, yes.
>
> There are two tokens, "print9" (a name) and ".0" (a float constant) --
> looks like SyntaxError to me.

Yep.  Looks that way to me, too.

Python 2.7.0+ (release27-maint:82569, Jul  5 2010, 08:35:08)
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from cStringIO import StringIO
>>> import tokenize, token
>>> for tok in tokenize.generate_tokens(StringIO("print9.0").readline):
...     print token.tok_name[tok[0]], tok[1]
...
NAME print9
NUMBER .0
ENDMARKER

--
Mark



More information about the Python-list mailing list