fork download
  1. class Bar:
  2. def __init__(self, foo_):
  3. self.foo_dict = {}
  4. self.foo = foo_
  5.  
  6. @property
  7. def foo(self):
  8. return self.foo_dict["foo_key"]
  9.  
  10. @foo.setter
  11. def foo(self, value):
  12. self.foo_dict["foo_key"] = value
  13.  
  14. def show(self):
  15. print("foo={} ; foo_dict['foo_key']={}".format(
  16. self.foo, self.foo_dict["foo_key"]))
  17.  
  18. b = Bar(1)
  19. b.show()
  20. b.foo = 2
  21. b.show()
  22. b.foo_dict["foo_key"] = 3
  23. b.show()
Success #stdin #stdout 0.03s 9984KB
stdin
Standard input is empty
stdout
foo=1 ; foo_dict['foo_key']=1
foo=2 ; foo_dict['foo_key']=2
foo=3 ; foo_dict['foo_key']=3