Python Tutorial Was: Guido's regrets: filter and map

Erik Max Francis max at alcyone.com
Tue Nov 26 19:16:04 EST 2002


Terry Hancock wrote:

> # ... whereas using a literal ...
> myfunc(2)
> 
> # ... is like using lambda
> mydispatch(lambda x: 2)

Nitpick, that should be lambda: 2.

> These are not only shorter than the temporary variable/named-function
> versions, they are clearer -- since the name "a" doesn't carry any
> meaning.
> It's only conceivable meaning is transparently what it does (i.e.
> return a 2),
> so it serves no documentation purpose to name it. In this case,
> defining it
> in place really makes more sense.

I agree.  If lambdas, map, filter, and reduce were removed from the
language or merely deprecated, I would miss them.  I do not use them
constantly, but I do use them when they're the most readable and make
the most sense and would regret their loss.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Everyone wants to look good at his own funeral.
\__/ Louis Wu
    PyUID / http://www.alcyone.com/pyos/uid/
 A module for generating "unique" IDs in Python.



More information about the Python-list mailing list