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

John Roth johnroth at ameritech.net
Tue Nov 26 16:05:27 EST 2002


"Jeremy Fincher" <tweedgeezer at hotmail.com> wrote in message
news:698f09f8.0211261046.582254a5 at posting.google.com...
> Thomas Guettler <pan-newsreader at thomas-guettler.de> wrote in message
news:<pan.2002.11.24.08.05.38.521605.727 at thomas-guettler.de>...
> > I never liked filter, map and reduce.
> >
> > I think it would be good to remove them from the python tutorial.
> > I think the tutorial would be easier for newbies it
> > it would be smaller.
>
> The biggest problem with filter, map, and reduce is that they're
> functions, not methods.  All this discussion about list comprehensions
> versus filter/map ignores one major disadvantage of list
> comprehensions: that they only work with lists.  If filter/map/reduce
> had been *methods* on list objects, then a programmer could implement
> his own container objects (binary trees, subclasses of list, etc.)
> with their own filter/map/reduce methods to construct like containers,
> and people would be happier.

Well, both filter and map are defined only for lists, so list
comprehensions
don't provide a reduction of function there. Reduce is defined for
sequences.

I could see filter and reduce as methods. Since map is a function across
a number of input lists, I have a somewhat harder time seeing it that
way - it looks a bit assymetric to me.

John Roth

> Jeremy





More information about the Python-list mailing list