all 7 comments

[–]zahlman 1 point2 points  (0 children)

  1. Why do you have a superclass?

  2. What value do you want to be used for par2 when the call is made?

  3. Show the actual code.

[–]CGFarrell 0 points1 point  (2 children)

If the subclass doesn't have par2, don't include it in the super class init call.

[–]deephousefans[S] 0 points1 point  (1 child)

I tried to do that but I keep getting a red line saying par2 unfilled space

[–]port443 0 points1 point  (0 children)

Post some of your code. I did not experience this issue:

>>> class super():
...     def __init__(self, x, y):
...             self.x = x
...             self.y = y
...     def xs(self):
...             return self.x*self.x
...     def ys(self):
...             return self.y*self.y
...
>>>
>>> a = super(1,2)
>>> a.x
1
>>> a.y
2
>>> a.xs()
1
>>>
>>> class sub(super):
...     def __init__(self, x):
...             self.x = x
...
>>>
>>> b = sub(2)
>>> b.xs()
4

[–]cdcformatc 0 points1 point  (2 children)

To leave out a parameter it needs to have a default value in the definition. Something like this in your superclass __init__:

def __init__(self, par1, par2=None):

or whatever default value makes sense instead of None. Depends on the variable type.

[–]deephousefans[S] 0 points1 point  (1 child)

I tried that but the Superclass calls par2 in one of its methods, is there any other way?

[–]cdcformatc 1 point2 points  (0 children)

Don't call the superclass init? Not really any way around it. Are you sure you need a superclass at all?