class bunch(dict): def __init__(self,**kw): dict.__init__(self,kw) self.__dict__.update(kw)
Usage is simple.
>>> o = bunch(a='A', b='B') >>> o {'a': 'A', 'b': 'B'} >>> o.a 'A' >>> o.b 'B' >>>
You can use it as both an object and dict.
11384 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
class bunch(dict): def __init__(self,**kw): dict.__init__(self,kw) self.__dict__.update(kw)
>>> o = bunch(a='A', b='B') >>> o {'a': 'A', 'b': 'B'} >>> o.a 'A' >>> o.b 'B' >>>
You need to create an account or log in to post comments to this site.