Consider the following example:
class Ciao():
a = 1
def whatIsIt(self):
print(self.a)
i = Ciao()
i.a = 2
i.whatIsIt() #Returns 2
I am creating an instance of the class Ciao, modifying the class variable and then printing it in the last line. To me, the class variable a, after having create the object i, behaves completely as the instance variable in this code snippet.
class Ciao2():
def __init__(self):
self.a = None
def whatIsIt(self):
print(self.a)
i = Ciao2()
i.a = 2
i.whatIsIt() #Returns 2
Is there any fundamental difference between a class and an instance variable after having instantiate the object?