I am new in python i read about Instance variable:
A variable that is defined inside a method and belongs only to the current instance of a class.
So i test it:
Consider this code:
class test:
count=0
def __init__(self):
test.count += 1
I have a class that add count after Instantiation. I run this:
t1=test()
t1.count=100
and then I create new instance:
t2=test()
t2.count # 2
then create another instance:
t3=test()
t3.count # 3
t2.count # 3
and then :
t1.count # I get 100
My question is why t2
and t3
was update but if change value of instance variable of specific instance the instance 's instance variable was not update?