dynamic function

Terry Reedy tjreedy at udel.edu
Mon May 10 13:17:15 EDT 2004


"Xaver Hinterhuber" <xaver_hinterhuber at web.de> wrote in message
news:c7ngg7$p1$1 at online.de...
> Hello pythonistas,
>
> I have programmed a product in Zope which allows me to source code on the
> web.
> Now I want to compile the code into a function and execute the function.

If the source is a comple def statement with a know name...

>>> exec "def f(): return 'this works'"
>>> f()
'this works'

Terry J. Reedy







More information about the Python-list mailing list