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

John Roth johnroth at ameritech.net
Sat Nov 30 09:45:04 EST 2002


"Louis M. Pecora" <pecora at anvil.nrl.navy.mil> wrote in message
news:291120020841221805%pecora at anvil.nrl.navy.mil...
> In article <3DE49902.BE880724 at alcyone.com>, Erik Max Francis
> <max at alcyone.com> wrote:
>
> > Yes, it does, but it also means that everyone who ever wants to
> > implement a sequence type needs to define __filter__ and __map__
methods
> > (say) or you can't do filtering and mapping with them.  Filter and
map
> > are general algorithms over sequence types -- all you need to use
them
> > is iteration, which is what all sequence types have in common.
>
> Python dummy question:  If you want them as methods, can't you just
> "overload" them to output the particular sequence.  Otherwise if you
> don't want to bother, you still have them as list returns.  Best of
> both worlds?

That would be true if your sequence type inherited from one
of the existing sequence types. Most classes that implement
(parts of) the sequence interface don't do that.

John Roth
>
> --
> Lou Pecora
>   - My views are my own.





More information about the Python-list mailing list