Say i have a class:
class Foo(object): def __init__(self,d): self.d=d d={\'a\':1,\'b\':2} inst=Foo(d) inst.d Out[315]: {\'a\': 1, \'b\': 2} >
You can also use __getattr__.
__getattr__
class Foo(object): def __init__(self, d): self.d = d def __getattr__(self, name): return self.d[name]