Subclassing with similar init method

In the following situation:

class X:
    def __init__(self, a, b, c, d, e, f, g, h, i ,j, k, l, m, n, o, p):
        ...CODE OMMITED FOR BREVITY...


class Y(X):
    def __init__(self, new, a, b, c, d, e, f, g, h, i ,j, k, l, m, n, o, p):
        super().__init__(a, b, c, d, e, f, g, h, i ,j, k, l, m, n, o, p)
        self.new = new

Is it the case that I have to duplicate all the variables into the signature of Y’s init? Is there a way to do this so I can assume that I’m going to get all the init parameters for X and just show the new parameters in Y’s init?

16 parameters to any method or function, not just an __init__, is a
terrible code smell :frowning:

But you can do this:

class Y(X):
    def __init__(self, new, *args):
        super().__init__(self, *args)
        self.new = new
1 Like

Ah I see, thanks for showing me how I could deal with this.

I agree about the 16 parameters - I just made it as an example and wouldn’t ever do that in practice.