[Tutor] exec versus execfile
Sun, 24 Sep 2000 12:19:23 -0500
I have a little Web application that will allow the user to type in some
code which is then interpreted and the result (in this case an image -
generated with PIL) will be returned.
Here my problem:
When I say: 'exec code' it gives me a syntax error. But if I save my code
into a file and use 'execfile(filename)' everything works fine. This
problem only occurs, if I have multiple lines in my code string. I noticed
that the file uses '\015\012' to finish a line and my code string only uses
'\012'. Is that a problem?
If I read the code I just saved to the file and try to exec it, the syntax
error is thrown again.
I am really confused, why it is not working. I am using Python 1.5.2. Can
someone shine some light on my situation?
Thanks in advance.
CBU - Physics and Chemistry Student
Web2k - Web Design/Development & Technical Project Management