Let's Talk About Lambda Functions!

Steve Holden sholden at holdenweb.com
Mon Aug 5 08:08:13 EDT 2002


"John Roth" <johnroth at ameritech.net> wrote in message
news:ukspe5tfe00374 at news.supernews.com...
>
> "Emile van Sebille" <emile at fenx.com> wrote in message
> news:89m39.786016$cQ3.120624 at sccrnsc01...
> > John Roth
> > > For example (and this is the example in the draft PEP on my disk)
> > >
> > > x = (
> > >     def (a, b):
> > >         print a
> > >         print b
> > >     )
> > >
> >
> > I have little doubt I'm missing the point here, having just got back
> > from a week off, but how does this differ from:
> >
> > def x(a, b):
> >     print a
> >     print b
>
> It's an anonymous function, embedded in an expression, with full syntax.
> That's something you can't do today using lambda()
>

Your example might be better shown as

x = some_function(arg1, arg2, arg3=(
    def(a,b):
        print a
        print b
    )
)

This at least has the merit of making it clearer that the anonymity is the
point of the whole thing (I nearly wrote "mess" there, sorry, I really do
feel this is attemtping to fix what needs no fix).

regards
-----------------------------------------------------------------------
Steve Holden                                 http://www.holdenweb.com/
Python Web Programming                http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------








More information about the Python-list mailing list