map

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Mon Aug 31 14:16:57 CEST 2009


On Mon, 31 Aug 2009 10:43:07 +0200, Hendrik van Rooyen wrote:

> Here is some heretical advice:
> 
> Do not use stuff like map and reduce unless they fit what you want to do
> perfectly, and "JustWorks" the first time.
> 
> You have a very clear idea of what you want to do, so why do you not
> just simply write something to do it?

That's not heretical advice -- that's pretty standard, vanilla, boring 
advice. It's probably good advice, if you care more about Getting the Job 
Done than about learning the language.


> And the advantage is that you do not have to remember what map does...

map() is probably the simplest, most straightforward of the functional 
tools in Python. It's harder for me to remember it's name than to 
remember what it does: it applies a function to each element of a list, 
instead of two the entire list as a single argument. Easy-peasy.

> *ducks away from the inevitable flames*

You'll have to try harder than that to get flamed :)



-- 
Steven



More information about the Python-list mailing list