Uwe.Mayer at ifib.uni-karlsruhe.de
Mon Jun 24 11:20:37 CEST 2002
is it possible to to write a class which, f.e. takes an argument in
__init__() and that doesn't return an instance object but a new class
The problem is that I've got a base class and there should be many
subclasses of it. Each subclass just overwriting an output method and
serving as a template:
I need many, many of these "template" classes, so a sorter way would be
to accustom the base class to take another argument which then outputs
the right thing:
def __init__(self, text):
template1 = base2('some text')
template2 = base2('another example')
My problem with this is that this produces instance objects and in the
above example I had class objects. I can hardly use the latter case
because I would always modify the original.
I also cannot create new templates as I need them, because I'm writing
utility classes which are much more complex and take much more
Is it somehow possible to have the "base2" class return a class instead
of an instance?
Is there another way to solve this problem?
Thanks in advance
More information about the Python-list