class Test1:
def __init__(self):
self.x = 1
class Test2(Test1):
# how can I get parent class's self.x ??
# exactly here not def __init__(self) or other methods in Test2..
Please… I spent hours figuring out how to get parent class’ self! and failed..
I need a python expert!
Do you want something like this?
You can access self.x inside Test2, because the Test2 object has the x attribute. It is created in Test1 initializer.
Edit: After the author explaining my misunderstanding, it is not possible to do what is asked, because x is an instance member, and not a class one. See gecco’s answer.