count method only for lists?

Fredrik Lundh fredrik at
Fri Aug 27 03:29:08 EDT 1999

Stuart Reynolds <S.I.Reynolds at> 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
    related operations.

> It seems as though the Python Library Reference (
> 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 mailing list