How can I change a class object with some rules when it assigned? for example:
class Foo:
x=0
if x < 0:
x = -1
else:
x = 1
p = Foo()
p.x = 1234
print(p.X)
So when I print p.x I expect 1 to be printed. but 1234 is printed. What should I do?