Reputation: 16295
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
Upvotes: 20
Views: 23633
Reputation:
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
.
Upvotes: 24