list.count() with no arguments

"Martin v. Löwis" martin at v.loewis.de
Sun Mar 27 13:15:58 EST 2005


Johan Hahn wrote:
> Wouldn't it be nice if list.count, called without any arguments,
> returned a dict with the list's unique items as keys and their
> frequency of occurance as values?

No. It would require all sequences to support this protocol, which
would be tedious to implement. Some day, we may have a bag type,
so it would be better if this type supported frequency counting.

Regards,
Martin



More information about the Python-list mailing list