Everyone hello. I have learning Python for 2 months, and now I am learning OOP. And I have a question:
class Test():
x = 0
def __init__(self):
if Test.x == 5:
print("OK")
else:
print("ERROR")
i = Test()
i.x = 5
And this is output:
ERROR
Why this code returns me an "ERROR", if x = 5? In my opinion it may return me an "OK"
Aucun commentaire:
Enregistrer un commentaire