Collection of a bunch of named stuff
1 2 class bunch(dict): 3 def __init__(self,**kw): 4 dict.__init__(self,kw) 5 self.__dict__.update(kw)
Usage is simple.
1 2 >>> o = bunch(a='A', b='B') 3 >>> o 4 {'a': 'A', 'b': 'B'} 5 >>> o.a 6 'A' 7 >>> o.b 8 'B' 9 >>>
You can use it as both an object and dict.