class A:
def __init__(self):
self.name = None
self.a = 10
self.b = 20
self.c = 30
def func1(self, param1, param2):
def inner_func1(self, param1, param2):
print(self, self.a, self.b)
inner_func1(self, param1, param2)
a = A()
print(a)
a.func1(1,2)
My first question -- is it legal to pass self
parameter to the class method's nested function? I run this code on python-3.5.2 with no problems, and both print()
display the same address of the class A instance. However python-3.6 complains on line print(self, self.a, self.b)
that self
has no member a
.
Also interesting is that PyCharm
IDE does not highlight self
on this line, and says that it "outshades the outer scope".
What exactly am I doing wrong?