class Example:
text = "Hello World"
def function():
print(text)
Example.function()
Example.printText()
throws this error NameError: name 'text' is not defined
Why doesn't printText()
remember the class attribute text
?
Does it have something to do with order python interprets the code?