fork download
  1. class Props(object):
  2. _x = 0
  3. #@property
  4. def x(self):
  5. print "get x"
  6. return self._x
  7. #@x.setter
  8. def x(self, x):
  9. print "set x"
  10. self._x = x
  11.  
  12. props = Props()
  13. print str(dir(props))
  14. print str(props.x)
  15. props.x = 5
  16. print props.x
  17.  
  18. print str(dir(props))
Success #stdin #stdout 0.03s 6356KB
stdin
Standard input is empty
stdout
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_x', 'x']
<bound method Props.x of <__main__.Props object at 0x82b510c>>
5
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_x', 'x']