anonymous functions,classes?
Steve Holden
sholden at holdenweb.com
Wed Nov 14 12:16:13 EST 2001
More information about the Python-list mailing list
Wed Nov 14 12:16:13 EST 2001
- Previous message (by thread): help for beginner !
- Next message (by thread): anonymous functions,classes?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Peter Bismuti" <peterb at cortland.com> wrote ... > Anonymous was the word I was looking for in my previous post. I want to > pass a function as an argument but don't want to have to define it globally. > 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. > Correct. The nearest thing Python has to anonymous functions is lambda expressions, but of course they can't be multiline. >>> def f(ff): ... return ff(12) ... >>> f(lambda x: x*x) 144 >>> regards Steve -- http://www.holdenweb.com/
- Previous message (by thread): help for beginner !
- Next message (by thread): anonymous functions,classes?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list