sending a function on the fly?

Max M maxm at
Thu Nov 15 11:08:50 CET 2001

"Peter Bismuti" <peterb at> wrote in message
news:3bf2a06f$1 at

> In ECMAscript you can send a function as an argument that is defined on
> fly such as:
> callMyFunction( new Function(){ blah blah })
> Something like that. Here the function has not been named and was not
> defined outside of the call.   Can this be done in Python?

Maybe the exec function can be used instead?

functionText = """
def hello():
    print 'Hello World'


>>> Hello World

Regards Max M

More information about the Python-list mailing list