How can I use the function "function" in the "new" module to create a function with arguments?

a.klostermann a.klostermann at kliniken-ruhrhalbinsel.de
Thu Oct 10 05:15:31 EDT 2002


I want to implement something like the Remote Method Interface, and so
I need to append a new, dynamically generated, method to the Interface
Object on the client side.

at the moment I only know how to generate python code in the form


    c = compile ("print 'hello'", "<string>","exec")

now I create a function object, binding it to a class instance as new
Method "hello"

    a.hello = (c, {})

the "{}" satisfies the globals argument with an empty dictionary, eg.
no globals.
But I want to provide arguments to the dynamically created function...
how can I do that?

Thanks in Advance,
Andreas Klostermann



More information about the Python-list mailing list