manstey wrote: > The ipo class has three basic methods, namely, get, set, and > run_obj_method (which takes the Cache class method, as its first > argument, and the list of its arguments as the second argument) > > e.g. > >>> CacheClass=ipo() > >>> CacheClass.set('Name','John') > >>> valName = CacheClass.get('Name') > >>> print valName > 'John' > > I want to add functionality to ipo, so I have wrapped a new style class > (MyWrapper class, very basic) around it. > > PythonCacheClass=MyWrapper(CacheClass) > > Now, I want to make PythonCacheClass more pythonic, so I have a > dictionary of all the properties and values of each ipo. Eg > > dicCacheProperties = {'Name':'John', 'Address':'The Strand'} etc > for key, val in dicCacheProperties.iteritems(): > setattr(PythonCacheClass, key, val) > > So now I have: > >>>print PythonCacheClass.Name > 'John' > > My problem is this: how do I link the set and get methods of the ipo > class with the set and get methods in the wrapper class > PythonCacheClass? > > So, I would like the following code: > >>> PythonCacheClass.Name='Alexander' > to execute automatically > CacheClass.set('Name','Alexander') etc >
Maybe try: class WrapperClass(BaseClass, object): get = object.__getattribute__ set = object.__setattr_ Gerard -- http://mail.python.org/mailman/listinfo/python-list