better lambda support in the future?
apardon at forel.vub.ac.be
Tue Dec 21 14:30:03 CET 2004
Op 2004-12-17, Terry Reedy schreef <tjreedy at udel.edu>:
> "Jason Zheng" <jzheng at jpl.nasa.gov> wrote in message
> news:cpvhee$7uh$1 at nntp1.jpl.nasa.gov...
>> Steven Bethard wrote:
>>> Jason Zheng wrote:
>>>> I'm wondering why python still has limited lambda support. What's
>>>> stopping the developers of python to support more lisp-like lambda
> They already have: given the fundamental syntax difference between all
> expressions and expressions within statements, def statements are at least
> the equivalent of lisp lambdas + name binding. When you get an exception
> traceback, a unique name is more helpful than the pseudoname <lambda>.
> Isolating the definition of a function in a separate statement also makes
> it possible to unittest the function.
>>> This comes up every few weeks on the list. If you haven't already,
>>> check the archives in Google for 'anonymous def' or 'anonymous
>>> function'. The usual response to this question is something along the
>>> lines of "if it's good enough to create a function for, it's good enough
>>> to name".
> What puzzles me is 1) why some people apparently think anonymity is good --
> is it really that hard to name non-trivial functions?
Do you name every object, number, string ... before you use it.
If not it seems you don't object to anonymity.
And yes it sometimes is hard. Of course you can just name it f1, f2 etc,
but that is no improvement over anonymity and sometimes the best you
can do is describe what the function does, but the code does that
More information about the Python-list