Exec Statement Question

Victor Subervi victorsubervi at gmail.com
Sun Nov 29 21:11:13 CET 2009


Hi;
I have the following line of code:

exec('%s()' % table)

where 'table' is a variable in a for loop that calls variables from another
script. I've made it so that it only calls one variable. I know for a fact
that it's calling that variable in the script because it found errors in
that script. I've tried to have it return the following:

print 'hi'
return 'hi'

It doesn't return anything. No errors are thrown because the code evaluates.
I don't know how to capture the output. I would like to do something like:

print exec(...)

or

var = exec(...)

but of course those options don't work. Suggestions?
TIA,
Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091129/da5cb5ab/attachment.html>


More information about the Python-list mailing list