Alex Martelli aleaxit at
Thu May 24 06:21:39 EDT 2001

"Duncan Booth" <duncan at> wrote in message
news:Xns90AB6AF2DA789duncanrcpcouk at
> Laura Creighton <lac at> wrote in
> news:mailman.990635563.6483.python-list at
> > If I had just used w.grid up there I would get a yellow button with
> > pink text.   This form is concise.  What do the lambda dislikers
> > suggest I do instead?  (This is a serious question)
> If you are using Python 2.1, then the lambda form becomes much neater:

...but so does the named-function form, equally -- see my latest
post in this thread.  Nested scopes apply in just the same way to
lambda's and to normal (named) nested functions.

As was noted in another post, nested scopes don't let you REBIND
the local variables of the function you're nested in -- lambdas
can't rebind anything anyhow, of course -- well I guess one COULD
use an elegant and readable construct such as:

    lambda x: setattr(sys.module[__name__], 'k', k+x) or k

to get an unnamed equivalent of

    def adder(x):
        global k
        k += x
        return k

but then the PSU might

More information about the Python-list mailing list