fork download
  1. class Hoge:
  2. def __init__(self,x,y):
  3. self.__x = x
  4. self.__y = y
  5.  
  6. @classmethod
  7. def sum(self,x=None,y=None):
  8. if x==None and y==None:
  9. print(self.x, self.y)
  10. try:
  11. print(self.__x)
  12. except:
  13. self.error()
  14. else:
  15. print(x+y)
  16.  
  17. @classmethod
  18. def error(self):
  19. print('error')
  20. print(self.x)
  21.  
  22. @property
  23. def x(self):
  24. return self.__x
  25.  
  26. @property
  27. def y(self):
  28. return self.__y
  29.  
  30. h = Hoge(10,20)
  31. h.sum()
  32. h.sum(h.x, h.y)
  33.  
  34. Hoge.sum(33,44)
Success #stdin #stdout 0.02s 9344KB
stdin
Standard input is empty
stdout
<property object at 0x2b77b5402e08> <property object at 0x2b77b547b408>
error
<property object at 0x2b77b5402e08>
30
77