[Tutor] Calling super classs __init__?
allen.fowler at yahoo.com
Wed Mar 19 04:55:55 CET 2008
> > class MySubClass(MySuperClass):
> > def __init__(self, just_a_sub_option): # what about other args? **args?
> I think I would go ahead and list the superclass parameters and put the
> new one at the end:
> def __init__(self, opt_1, opt_2, opt_3, opt_n, just_a_sub_option):
> > MySuperClass.__init__() # Should this be first?
> What args to use? **args?
> MySuperClass.__init__(self, opt_1, opt_2, opt_3, opt_n)
> John's method will also work but I prefer to add the new parameter at
> the end of the argument list.
(Hmm.. I should have pointed out that I generally use keyword args. )
Right. So, I can certainly call the MySuperClass.__init__() with a long list of kwargs, but that gets annoying quickly when the superclass is also under active development and it's call signature frequently changes.
Never miss a thing. Make Yahoo your home page.
More information about the Tutor