count method only for lists?
fredrik at pythonware.com
Fri Aug 27 09:29:08 CEST 1999
Stuart Reynolds <S.I.Reynolds at cs.bham.ac.uk> wrote:
> Does anyone know why there the count method is only defined for mutable
> sequences (i.e. lists) and not strings and tuples?
"Good question", to quote the FAQ.
in the old days, the answer used to be 'the design rule is that
immutable objects don't have methods', but that's no longer
true. strings are likely to grow methods in 1.6, for example.
and complex numbers already have them...
FAQ 6.4 gives the true background:
Long ago, it seemed unnecessary to implement any of
these functions in C, so a standard library module "string"
written in Python was created that performs string
> It seems as though the Python Library Reference (126.96.36.199
> Mutable Sequence Types) only describes lists and not
> mutable sequence types.
well, strings and tuples are not mutable, so that's
More information about the Python-list