comprehensions was Re: Switch statements again
vvainio at tp.spt.fi
Fri Jan 17 12:54:31 CET 2003
Jack Diederich <jack at performancedrivers.com> wrote in message news:<mailman.1042740101.18359.python-list at python.org>...
> Less of a good reason, but map() and filter() exist in other languages
> so they are more broadly recognizable even to newbies.
My own experience, and that of some of the colleagues to whom I have
introduced Python, is that map and filter are easier to learn and
understand initially (perhaps because they are familiar from other
contexts, perhaps because there is no special syntax, just builtin
functions), but harder to use when you are actually writing (and
especially reading) code.
Me, I actually convert every map/filter I encounter in my old code to
list comprehensions, just for the sake of readability. I tend to think
that tutorials and such should not beat the drum for map/filter/lambda
too loudly, to avoid giving people bad habits.
Of course, there is still the embarrassing issue of the list
comprehension variable not being local to the list comprehension. Why,
oh why won't people pre-deprecate it... at least in the documentation.
Any hope to get it into the tutorial/lang reference for 2.3 :)?
More information about the Python-list