
April 15, 2010
2:20 a.m.
On Wed, Apr 14, 2010 at 11:02:54PM -0700, alex23 wrote:
On Apr 15, 3:02?pm, "C. Titus Brown" <c...@msu.edu> wrote:
? ?b = bag(foo=bar, baz=bif)
? ?assert b.foo == bar ? ?assert b.bz == bif
I've always known this as a 'bunch' after Alex Martelli's recipe[1]. It's handy, but at 3 lines of code not an urgent candidate (IMO) for stdlib:
class Bunch: def __init__(self, **kwds): self.__dict__.update(kwds)
[1]: http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-...
Well, yes -- but 'sets' weren't exactly rocket science either, and I find them really useful, too :). --titus -- C. Titus Brown, ctb@msu.edu