Take a look at this class:
class Signal:
point = None
view = {
"x": None,
"y": None,
}
def __init__(self, point):
self.point = point
self.set_position()
print(self.point + " -> " + str(self.view["x"]) + "x" + str(self.view["y"]))
def set_position(self):
if self.point == "north":
self.view["x"] = 150
self.view["y"] = 200
else:
self.view["x"] = 300
self.view["y"] = 400
def check(self):
print(self.point + " -> " + str(self.view["x"]) + "x" + str(self.view["y"]))
And now in the following result when instantiating 2 different variables like this object and checking the values:
>>> s1 = Signal("north")
north -> 150x200
>>> s2 = Signal("south")
south -> 300x400
>>> s1.check()
north -> 300x400
I just can not find the logic of this. Can you explain me why creating% with% values of s2
are exchanged?