EXECing multiple lines.

Joonas Paalasmaa joonas at olen.to
Tue Jun 12 01:43:44 EDT 2001


Joshua Marshall wrote:
> 
> Joonas Paalasmaa <joonas at olen.to> wrote:
> > What might be wrong when I get the following error?
> 
> >>>> exec """for x in range(5):
> >     print x"""
> > Traceback (innermost last):
> >   File "<pyshell#3>", line 1, in ?
> >     exec """for x in range(5):
> >   File "<string>", line 2
> >     print x
> >           ^
> > SyntaxError: invalid syntax
> >>>>
> 
> It works if you put a newline at the end.  I don't know if it's a bug
> that it doesn't work without the newline.
Strange. But now it works.



More information about the Python-list mailing list