[Tutor] executing a string representing python code
Cecilia Alm
flickita at gmail.com
Fri Mar 2 15:32:40 CET 2007
I know that there are several ways to execute a string which represents a
piece of python code.
Out of curiosity, is it only eval which returns a value? (as below, where
the string corresponds to a defined function).
>>> def addone(val):
... return val + 1
...
>>> res = eval('addone(10)')
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070302/9cb8ce53/attachment.htm
More information about the Tutor
mailing list