Generic Python
Kragen Sitaker
kragen at pobox.com
Mon Jun 24 18:00:55 EDT 2002
Uwe Mayer <Uwe.Mayer at ifib.uni-karlsruhe.de> writes:
> 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:
> ...
> Is there another way to solve this problem?
Several people have offered ways to do this with metaclasses or
run-time code generation with exec, but I agree with Michael Chermside
that you should use a factory function or just override the output
method on individual instances instead.
More information about the Python-list
mailing list