[Tutor] Error Using exec to Run Module Files

Knacktus knacktus at googlemail.com
Wed Aug 18 07:45:22 CEST 2010

Am 18.08.2010 06:54, schrieb mesrod at juno.com:
> I'm a rank beginner in Python.  Took advantage of the O'Reilly one-day sale of 'Learning Python' announced on the tutor, and starting to work my way through it.  When I tried out an example from pg57, on Using exec to Run Module Files, I get the following result:
>>>> exec(open('script1.py').read())
> Traceback (most recent call last):
>    File "<stdin>", line 1, in<module>
>    File "<string>", line 1
>      %!PS-Adobe-3.0
>      ^
> SyntaxError: invalid syntax
It looks like the first line of your file "script1.py" contains 
"%!PS-Adobe-3.0". (Which is no valid syntax, of course)
Have you doublechecked the content of script1.py and does it work by 
invoking it form the command line with "python script1.py"? My guess is 
the file somehow got screwed up.



> What is going on/
> Gene R.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

More information about the Tutor mailing list