Thank you both. If I understand correctly, I have two new ways to creating my new classes:
class _Communicate(commandset2.CommandSet_Communicate): __metaclass__ = My_meta or _Communicate = create_wrapper_class |('_Communicate',commandset2.CommandSet_Communicate) and also two new ways to check for callable methods :~) hasattr(attr,"__call__") or inspect.isfunction(attr) Gerard points out that I can re-define the callable methods instead of using dynamic over-ride at each method call. It's left as an exercise for the reader to determine the behaviour of derived classes :~) Carl points out that unless the methods are required to be static methods, I can use a wrapper function from the parent object, instead of a wrapper function from the parent class. And I can use a variable for my wrapper_function base class: self, or self.parent Two new words are introduced: 'type' and 'super'. ...That part is still opaque to me... I also don't know why the example meta class is derived from 'type'. The project is to interchangeably replace an object with a similar group of objects. The original project was not built with this in mind: there is no-one here qualified to design that kind of project. So I'm retrofitting the original model by modification. Successive attempts have involved more and more complex modifications. In retrospect, the project has three parts: remove side effects, push side effects to a common location, modify code so that changes only affect areas that encapsulate side effects. This code allows top level code to pretend that the intermediate code has not changed. regards (david) "bambam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I have a class containing a series of classes like this: > > class Th(Externaldevice): > class _Communicate(commandset2.CommandSet_Communicate): > def __getattribute__(self,attrname): > attr = > commandset2.CommandSet_Communicate.__getattribute__(self,attrname) > if "__call__" in dir(attr): > return functools.partial(Th._wrapper_function, self.parent, attr) > else: > return attr > > class _System(commandset2.CommandSet_System): > def __getattribute__(self,attrname): > attr = commandset2.System_Communicate.__getattribute__(self,attrname) > if "__call__" in dir(attr): > return functools.partial(Th._wrapper_function, self.parent, attr) > else: > return attr > > That is, a a wrapper function is applied to a bunch of methods in a bunch > of classes. > The class declarations are simple, but even so, repetitive. > Can anyone suggest a more compact representation for the class > declarations? > Also, because the parent class name is given explicitly in the class > declarations, I can't over-ride the _wrapper_function in a child class, > except by over-riding each of the class declarations. Is there a way to > reference the _wrapper_function just to the containing class? > > Steve > -- http://mail.python.org/mailman/listinfo/python-list