Returning instances of some other class is not so horrible. They're called FactoryMethods usually.
An example is when you have a polymorphic tree of image file reader objects, and you open an image file, it might return a JpegReader which ISA ImageReader or a TIFFReader which also ISA ImageReader, but you want all of the 'which class do I need for this data?' logic to be in one place. -Jim On 15 Jun 2005 03:12:07 -0700, Michele Simionato <[EMAIL PROTECTED]> 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! > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org/mailman/listinfo/python-list