__init__ keyword param for sub-class?
Grant Edwards
grant at nowhere.
Thu Dec 23 14:06:12 EST 1999
I want to sub-class something that takes one positional and a
whole slew of keyword arguements when the object is
instantiated, and I want to add one keyword argument (keyword
'myoption' in the below example) to be handled by my method,
and pass the rest on the the super-class. I couldn't find any
examples of this type of thing, so this is what I came up with:
class execWindow(Pmw.ScrolledText):
def __init__(self, *posArgs, **keyArgs):
if keyArgs.has_key('myoption'):
self.__myoption = keyArgs['myoption']
del keyArgs['myoption']
return apply(Pmw.ScrolledText.__init__, (self,) + posArgs, keyArgs)
[ various other methods and stuff ]
Is this the "right" way to do this?
--
Grant Edwards grante Yow! I just got my PRINCE
at bumper sticker... But now I
visi.com can't remember WHO he is...
More information about the Python-list
mailing list