Say we have a class:
class Foo (object):
... def __init__(self,d):
... self.d=d
... def return_d(self):
... return self.d
... and a dict:
d={'k1':1,'k2':2}
... and an instance:
inst=Foo(d)
Is there a way to dynamically add attributes to return_d
so:
inst.return_d.k1
would return 1?