Favorite non-python language trick?

Steven D'Aprano steve at REMOVETHIScyber.com.au
Sat Jun 25 22:09:29 EDT 2005


On Sat, 25 Jun 2005 13:31:19 -0700, Robert Kern wrote:

> Of course, in a Python 3000 world, nothing stops anyone from using their 
> own extension module implementing map, filter, and reduce if they really 
> want to. TSBOOOWTDI in the language/stdlib, but it shouldn't stop anyone 
> from using other ways to do it that aren't in the stdlib if the 
> tradeoffs are right for them.

Now that's a good point. Since Guido has said that one of the major
motivations for removing the functional programming tools like map, filter
and reduce is that There Should Be Only One Obvious Way To Do It, and
Guido also seems to really like list comprehensions, is it fair to
assume that for-loops will be removed from Python 3000 too?

Or are they safe until Python 4000?

*wink*

Of course, I also know that Guido has said a foolish consistency
is the hobgoblin of little minds, and I would never accuse him of being a
little mind. But one of the things I like about Python is that it has
found a nice balance between There Is Always Another Way, and The Language
Is A Straight Jacket.

It is blindingly easy to refactor map and filter as in-line list comps,
and Guido's comments suggest to me that they are safe until list comps are
significantly faster. But reduce needs to be re-factored as a for loop,
with all the disadvantages that implies. I think that if people like
Mandus have good real-world usage cases for reduce, it can be saved, at
least as part of itertools.


-- 
Steven.




More information about the Python-list mailing list