List Count

Terry Jan Reedy tjreedy at udel.edu
Tue Apr 23 15:01:33 EDT 2013


On 4/23/2013 7:45 AM, Blind Anagram wrote:

> I then wondered why count for lists has no limits

Probably because no one has asked for such, as least partly because it 
is not really needed. In any case, .count(s) is a generic method. It is 
part of the definition of a Sequence. It can also be implemented for 
non-sequence collections, such as a Tree class, that allow multiple 
occurrences of an item.

 > whereas count for other objects (e.g. strings) has these.

Strings (of unicode or bytes) are exceptional in multiple ways.

--
Terry Jan Reedy





More information about the Python-list mailing list