Theoretical question about Lambda

Steve Holden sholden at holdenweb.com
Thu May 2 16:18:31 EDT 2002


"Bengt Richter" <bokr at oz.net> wrote ...
> On Thu, 02 May 2002 17:00:11 GMT, Alex Martelli <aleax at aleax.it> wrote:
>
> >Bengt Richter wrote:
> >        ...
> >>>> Is there any forced need for Lambda's in Python ? I mean does Lambda
> >>>> contribute anything that cannot be done otherwise in Python ?
> >>>
> >>>Not really.  lambda lets you have an anonymous function, and create
> >>>a function within an expression (while def is a statement and does
> >> A thought: being ble to do it in an expression allows taking advantage
> >> of short-circuit evaluation to avoid some problem in a lambda def form
> >> vs another.
> >
> >...while doing it with a def would let you much more easily with
> >an appropriate if/else:
> >
> >if doitoneway:
> >    def foo(): return whatever
> >else:
> >    def foo(): return somethingelse
> >
> What if doitoneway varies during expression evaluation involving foo,
> and whatever and somethingelse involve function calls with side effects?
> Would you pass all the unevaluated pieces to an outside function? I'm sure
> it would be cleaner sometimes, but I'm not sure about all the time.
> C'mon, you can argue both sides ;-)
>
> >> What do you think re short circuit evaluation vav lambda?
> >
> >Given the lack of a ternary operator in Python (insert appropriate
> >smiley fraction here), if/else is much more comfortable for this.
> >
> ISTM a real ternary or cond expression would be a good addition to Python.
>

Why don't you ask James Besemer what *he* thinks, I seem to remember he had
a few words on that subject a few days ago.

Or, alternatively ...


AAAARRRRGGGGHHHH!!!!

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








More information about the Python-list mailing list