David Mertz added the comment:

I definitely wouldn't want a mutator that "normalized" counts for the reason 
Antoine mentions.  It would be a common error to normalize then continue 
meaningless counting.

One could write a `Frequency` subclass easily enough.  The essential feature in 
my mind would be to keep an attribute `Counter.total` around to perform the 
normalization.  I'm +1 on adding that to `collections.Counter` itself.

I'm not sure if this would be better as an attribute kept directly or as a 
property that called `sum(self.values())` when accessed.  I believe that having 
`mycounter.total` would provide the right normalization in a clean API, and 
also expose easy access to other questions one would naturally ask (e.g. "How 
many observations were made?")

----------
nosy: +David Mertz

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25478>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to