anonymous functions? class?

Steve Holden sholden at
Thu Nov 15 21:34:55 CET 2001

[posted & mailed]

"Peter Bismuti" <peterb at> wrote in ...
> I want to pass a function as an argument but don't want to have to define
> globally.
> I think the proper terminology for this is "anonymous".
> The way I *don't* want to do it:
> def foo():
>     pass
> callFunction(foo)
> The way I want to do it:
> callFunction(def foo(): pass)
> I'm guessing this can't be done because of Python's indenting syntax.
> 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?

The answer is the same as yesterday: you must either define a function or
use a lambda. Didn't you see all those posts in reponse to your previous


More information about the Python-list mailing list