Multiline lamba implementation in python.
Steve Howell
showell30 at yahoo.com
Tue Jun 12 20:23:53 EDT 2007
--- Josh Gilbert <jgilbert.python at gmail.com> wrote:
>
> I know that the standard Python response is that you
> might as well define a
> function, indeed, the name might provide useful
> documentation. In reality,
> however, the vast majority of my anonymous functions
> are callbacks (tends to
> lead to names like mouseUp_callback) and functions
> passed into list
> comprehensions. I don't want to have to name them,
> it breaks the flow. My
> technique allows for anonymous functions of
> arbitrary complexity which is
> what I really want.
>
> I really don't think that I'm alone here, the lack
> of a multiline lambda has
> been bemoaned for years (recently here
> http://www.dehora.net/journal/2007/06/payne.html).
You're definitely not alone here. I don't question
the wisdom of people who reject anonymous methods in
the short term, as there are all kinds of valid
reasons for doing so (self-documentation,
anti-featuritis, incompatibility with Python syntax,
etc.), but any complaint that says "it breaks the
[mental] flow" resonates with me.
I sometimes wish *ALL* languages had an escape
mechanism, maybe with the keyword "escape," that
occasonially let you revert back to things that you
slightly miss about mostly abandoned languages:
Perl: escape Perl { # anonymous function }
C++: escape c++ allow_implicit_this
C: escape c struct complex {int real; int complex}
etc.
____________________________________________________________________________________
Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.
http://new.toolbar.yahoo.com/toolbar/features/mail/index.php
More information about the Python-list
mailing list