I've noticed something I'm confused about when creating member variables of a class, then setting their value in a class method. Essentially, in my program whenever I change both member variables in this function, they both change like they're supposed to. However, when I create any other instance of that class without calling the method that changes those member variables, only one stays the same.
class Game(object):
isGoing=True
board=[1,2,3]
def __init__(self,name):
self.name=name
def test(self):
self.board[0]="X"
self.isGoing=False
t1=Game("Testing")
t1.test()
print t1.isGoing
print t1.board
t2=Game("Testing")
print t2.isGoing
print t2.board
This will end up printing:
False
['X',2,3]
True
['X',2,3]
My question is, why did only the isGoing member variable revert back to True, and the board list stayed the same as it was?