Answer the question
In order to leave comments, you need to log in
Why doesn't an error occur?
Hello, I'm learning python OOP. I don't understand how we can access the self.x variable in the 5th line of the code? because self.x was declared in the local scope
class Point():
def __init__(self, x):
self.x = x
def func(self):
print(self.x)
p = Point(5)
p.func()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question