[Tutor] Calling super classs __init__?

Allen Fowler allen.fowler at yahoo.com
Wed Mar 19 01:24:36 CET 2008


Now, perhaps this not the best way write code, but I have a few questions regrading calling the super classes constructor:

I have a super class that accepts many arguments to it's constructor, and a subclass that should define one additional argument.

What's the most "pythonic" way to make this work?

class MySuperClass(object):
    def __init__(self, opt_1, opt_2, opt_3, opt_n):
       # stuff done here

class MySubClass(MySuperClass):

    def __init__(self, just_a_sub_option):  # what about other args? **args?
        # do stuff with "just_a_sub_option"
        MySuperClass.__init__()                    # Should this be first?  What args to use? **args?

Basically, I'd like to avoid maintaining a verbose list of arguments in the subclass.


Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

More information about the Tutor mailing list