[Python-ideas] question - 'bag' type
alex23
wuwei23 at gmail.com
Thu Apr 15 08:02:54 CEST 2010
On Apr 15, 3:02 pm, "C. Titus Brown" <c... at 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-a-bunch-of-named
More information about the Python-ideas
mailing list