Re: Simple Python implementation of bag/multiset

2008-06-19 Thread Terry Reedy
MRAB wrote: While another thread is talking about an ordered dict, I thought I'd try a simple implementation of a bag/multiset in Python. Comments/ suggestions welcome, etc. class bag(object): I would prefer a logical rather than alphs order to the methods. Certainly, starting with __init__

Simple Python implementation of bag/multiset

2008-06-19 Thread MRAB
While another thread is talking about an ordered dict, I thought I'd try a simple implementation of a bag/multiset in Python. Comments/ suggestions welcome, etc. class bag(object): def __add__(self, other): result = self.copy() for item, count in other.iteritems():