From bags to default dicts

Mark E. Fenner mfenner at gmail.com
Tue Sep 12 10:39:19 EDT 2006


Hello all,

I was curious if anyone has transitioned some code from using Raymond
Hettinger's bag class:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/259174

to using 2.5's collections.defaultdict.  Any pitfalls to watch out for?  It
seems we should be able to do slightly better than creating a bag class
that has a defaultdict as a member.  So, inheriting from defaultdict and
defining some of the nice utility methods that Hettinger's class defines
seems like the way to go.  Comments?

Regards,
Mark



More information about the Python-list mailing list