LAMBDA IS IT USELESS?

Bengt Richter bokr at accessone.com
Fri Jul 13 18:31:15 EDT 2001


On Fri, 13 Jul 2001 18:01:37 +0200, "Alex Martelli" <aleaxit at yahoo.com> wrote:
[...]
>or to the def.  The ONLY difference is that lambda generates an
>anonymous function (and is an expression), while def generates a
>named function (and is a statement).

In that case why not allow an anonymous version of def, e.g..,

    map(
        def(x):
            x**2
        ,xrange(5))

which would work like

    map(
        lambda x:x**2
        ,xrange(5))

(OTOH you could make lambda multi-line ;-)






More information about the Python-list mailing list