Re: Counter Class -- Bag/Multiset
- From: MRAB <google@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 23 Jan 2009 17:20:29 +0000
Terry Reedy wrote:
bearophileHUGS@xxxxxxxxx wrote:I would've limited the counts to non-negative values too, but being able
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
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
to store negative values does allow credit/debit or in-stock/on-order.
In such cases, the name 'Counter' makes more sense.
- Prev by Date: Re: Where to place imports
- Next by Date: Re: The First Law Of comp.lang.python Dynamics
- Previous by thread: Re: Counter Class -- Bag/Multiset
- Next by thread: Re: Counter Class -- Bag/Multiset