On Sat, Jul 23, 2005 at 11:30:19AM +0200, Bruno Desthuilliers wrote: > Thanos Tsouanas a écrit : > > class dictobj(dict): > > """ > > class dictobj(dict): > > A dictionary d with an object attached to it, > > which treats d['foo'] as d.obj.foo. > > """ > > def __init__(self, obj): > > self.obj = obj > > def __getitem__(self, key): > > return self.obj.__getattribute__(key) > > I'd replace this last line with: > return getattr(self.obj, key) > > Now given your specs, I don't see what's wrong with your solution.
I just dont want to use my class, if one already exists in the libraries (or any other way to achieve the same thing), that's all ;) Thanks for the tip. -- Thanos Tsouanas .: My Music: http://www.thanostsouanas.com/ http://thanos.sians.org/ .: Sians Music: http://www.sians.org/ -- http://mail.python.org/mailman/listinfo/python-list