define a new func on the fly?
Greg Ewing
greg at cosc.canterbury.ac.nz
Thu Mar 1 22:12:09 EST 2001
Bruce Edge wrote:
>
> Now, how can I get it to create this function in the global namespace?
exec "def xxx(): print \"xxxxxxxx\"" in globals()
(By the way, you don't need the parentheses around the string
to be exec'ed, because exec is a statement, not a function.)
--
Greg Ewing, Computer Science Dept, University of Canterbury,
Christchurch, New Zealand
To get my email address, please visit my web page:
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list