simple eval question

N Becker nbecker at fred.net
Fri Nov 2 21:41:28 CET 2001


What is wrong with this?

eval ("print \"hello\"')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<string>", line 1
    print "hello"
        ^
SyntaxError: invalid syntax

I expected that eval takes a string an evaluates it as input to the interpreter, 
as if it had been typed into the command line.  Was I wrong?



More information about the Python-list mailing list