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?
function is static you need to use self to access the object property like this:
if you want to keep it static use: