python - accessing superclass attributes
17,986
An Sub
is a Super
, i.e. all instances of Sub
can be treated exactly like instances of Super
. In your case, that means you simply set self.a = b
.
Related videos on Youtube
![Aly](https://i.stack.imgur.com/UvqyR.png?s=256&g=1)
Comments
-
Aly about 2 years
Hi I want to achieve the following in python, however I cant figure out what to replace the line
super.a = b
with:class Super: def __init__(self): self.a = 1 class Sub(Super): def method(self, b): super.a = b