eval string

Peter Otten __peter__ at web.de
Thu Sep 30 17:09:21 CEST 2010


Peter Otten wrote:

> exec 'import sys\nsys.stderr.write("completed!\n")'

Oops, you need to escape the backslashes for newlines inside quotes inside 
quotes:

>>> exec 'import sys\nsys.stderr.write("completed!\\n")'
completed!

Peter



More information about the Python-list mailing list