[Tutor] function that returns a fn
alan.gauld at freenet.co.uk
Sun Dec 12 18:20:55 CET 2004
> def getjlistrenderer(opname):
> def listrender():
> # use opname, eg ops=getlist(opname)
> # or set local fn variable
> return renderer;
> return listrender;
> #?or f=listrender(); return f;
> Is it really as simple as this?
Assuming your indentation is actually OK then yes, it is
as easy as that.
> books too, but thought I'd get some more pointers as well. Web
> so far only shows lambda, which is one-liner, and that won't do.
Lambda is actually a single *expression* which may cross several
lines. But with nested functions available lambda is the wrong way
to go for higher order programming in Python.
More information about the Tutor