Hello fine people of Stackoverflow!
I have a problem. I am trying to change an instance variable (which is on it's own a class instance) and for some reason, it changes the same instance variable for all instances of the original class.
here is the code:
#create State class
class State(object):
awake = False
#Set Person Class
class Person(object):
state = State()
#create person instences
jack = Person()
jill = Person()
print(jack.state.awake)
print(jill.state.awake)
#wake jill only
jill.state.awake = True
print("")
print(jack.state.awake)
print(jill.state.awake)
OUTPUT:
False
False
True
True
I am trying to wake jill only.