Counter Class -- Bag/Multiset

Terry Reedy tjreedy at udel.edu
Fri Jan 23 04:10:20 EST 2009


bearophileHUGS at lycos.com wrote:

> Also: what's the rationale of allowing negative values too?

I can guess two:
1) Nuisance to check given that Python does not have a count (0,1,2...) 
type.
2. Useful. + = items on hand; - = items back-ordered.
Bank account go negative also ;-). So does elevation.
Similarly, an app could set 0 to mean 'desired quantity on hand', so 
non-zero count is surplus or deficit.

I might not have thought to allow this, but it seems to open new 
applications.  (This definitely makes bag or multiset inappropriate as 
names.)

tjr




More information about the Python-list mailing list