Securing a future for anonymous functions in Python

Simo Melenius firstname.lastname at
Sat Jan 1 16:35:34 EST 2005

Doug Holton <a at b.c> writes:

> Steven Bethard wrote:
> > Simo Melenius wrote:
> >> map (def x:

Oops, I found a typo alreay. I meant to write "def (x):" -- no name
for anonymous functions but just the argument list, please :)

> Right the comma plus other things make this difficult for a parser to
> handle correctly.  Other people have already come up with working

It is difficult since in Python we don't enjoy the ugly luxury of
stuffing statements inside {}s. But as Bengt pointed out, parentheses
don't actually look bad at all in this case.

> Then the multi-line way.  I had to add an overload of map to support
> reversing the order of parameters (list first, then the closure):
> newlist = map([1,2,3,4,5,6]) def (x as int):
>       return x*x*x

That doesn't seem to scale if you want to pass more than one anonymous
function arguments to the function or call an arbitrary function with
parameters in arbitrary order.


More information about the Python-list mailing list