On Wed, 15 Jun 2005 03:12:07 -0700, Michele Simionato wrote: > Having a class that returns instances of some other class is horrible, but > since you asked for it: > > class A(object): pass > class B(object): pass > > class Foo(object): > def __new__(cls, arg): > if arg=="a": > return A() > else: > return B() > > print Foo("a") > print Foo("b") > > Michele Simionato > > P.S. don't do it!
Ciao Michele. I have n classes wich share the same interface. I then have a single class which add functionality to all the n classes, using their interface. The only way I see to make this single class inherith from the choosed nx class is this one. If there is a better approach, I can implement it. Thank you for the answer, Riccardo -- Riccardo Galli Sideralis Programs http://www.sideralis.net -- http://mail.python.org/mailman/listinfo/python-list