simple eval question

Michael Hudson mwh at python.net
Mon Nov 5 12:03:42 EST 2001


nbecker at fred.net (N Becker) writes:

> What is wrong with this?
> 
> eval ("print \"hello\"')

print is a statement.  eval evaluates an expression.

You could try

eval("sys.stdout.write('hello\n')")

or 

exec "print 'hello'"

Cheers,
M.

-- 
  I've reinvented the idea of variables and types as in a
  programming language, something I do on every project.
                                          -- Greg Ward, September 1998



More information about the Python-list mailing list