lots of similar classes?
boncelet
boncelet at udel.edu
Mon Jan 20 09:37:06 EST 2003
I want to create lots of similar classes and wonder what's the
best/most efficient way.
Pseudo-code looks like this:
class Super:
def __init__(self,name,lots_of_other_arguments):
self.name=name
<<set rest of arguments, etc>>
class A(Super):
def __init__(self,name='a',lots_of_other_arguments):
Super.__init__(self,name,lots_of_other_arguments)
There will be lots of these, eg., A, B, C etc. Most of these will
differ only in the name argument. In a few, I might want to use only
a subset of the "other arguments".
My problem is rewriting the "lot_of_other_arguments" over and over
again seems wasteful, error-prone, and fragile. Is there a better
way?
Thanks,
Charlie Boncelet <boncelet at udel.edu>
More information about the Python-list
mailing list