[Tutor] SubClassing

Jeff Shannon jeffshannon at gmail.com
Sun Feb 27 22:56:24 CET 2005

On Fri, 25 Feb 2005 05:54:39 -0200, Ismael Garrido
<ismaelgf at adinet.com.uy> wrote:
> def __init__(self, this, that, new):
>     Parent.__init__(self, this, that)  #note self
>     self.new = new

If the paren's init t has a lot of possible arguments, it may be
easier to do things this way:

class Child(Parent):
    def __init__(self, new, *args, **kwargs):
        Parent.__init__(self, *args, **kwargs)
        self.new = new

This way, the Child class doesn't need to know or care about what
parameters get passed on to Parent; it uses the ones it needs, and
passes all the rest on.

Jeff Shannon

More information about the Tutor mailing list