[Python-3000] ABC method mismatch

Alexander Belopolsky alexander.belopolsky at gmail.com
Thu Feb 7 16:18:05 CET 2008


Raymond Hettinger <python <at> rcn.com> writes:

> 
> [Fred Drake]
> > I'd be happy seeing these methods added to tuple; there's
> > no reason that they would only be useful on mutable sequences.
> 

Note that adding index and count to tuple will conflict with using these
names as attributes in classes generated by collections.namedtuple.
There is certain elegance in tuples and numbers having no non-
special methods.

What is the advantage of having count and index in Sequence ABC?
These methods are easily implementable as functions that take an
iterable (in fact, itertools.count already exists) and having them in
Sequence ABC puts an extra burden on implementors of concrete classes.



More information about the Python-3000 mailing list