map/filter/reduce/lambda opinions and background unscientific mini-survey

Steven Bethard steven.bethard at gmail.com
Fri Jul 1 13:24:50 EDT 2005


mcherm at gmail.com wrote:
> I avoid map sometimes, because I find its syntax less readable
> than list (and expression) comprehensions. But occasionally it
> is the most readable way to do something, and I wouldn't want to lose
> it.

I tend to avoid map as much as possible.  The only places I'm still 
tempted to use map is in cases like:

     ' '.join(map(str, objects))

But I'm slowly moving towards:

     ' '.join(str(o) for o in objects)

because it's easier to fix when I realize later that I should have written:

     ' '.join('x%sy' % o for o in objects)


In general, I don't think I'll really miss any of map, filter, reduce, 
etc.  My background's a lot of Java and and a little bit of LISP and ML. 
  I was never a fan of LISP, but I did like ML a lot.  However, for 
Python, I definitely find list comprehensions and generator expressions 
easier to read, especially when I have to read back through code I wrote 
a long time ago.

STeVe



More information about the Python-list mailing list