fork download
  1.  
  2. class Foo(object):
  3. def __init__(self, value):
  4. self.value = value
  5. def incr(self):
  6. self.value += 1
  7. def __add__(self, other):
  8. return int.__add__(self.value, other)
  9. def __sub__(self, other):
  10. return int.__sub__(self.value, other)
  11. def __mul__(self, other):
  12. return int.__mul__(self.value, other)
  13. def __floordiv__(self, other):
  14. return int.__floordiv__(self.value, other)
  15. def __mod__(self, other):
  16. return int.__mod__(self.value, other)
  17. def __divmod__(self, other):
  18. return int.__divmod__(self.value, other)
  19. def __pow__(self, other):
  20. return int.__pow__(self.value, other)
  21. def __lshift__(self, other):
  22. return int.__lshift__(self.value, other)
  23. def __rshift__(self, other):
  24. return int.__rshift__(self.value, other)
  25. def __and__(self, other):
  26. return int.__and__(self.value, other)
  27. def __xor__(self, other):
  28. return int.__xor__(self.value, other)
  29. def __or__(self, other):
  30. return int.__or__(self.value, other)
  31. def __radd__(self, other):
  32. return int.__radd__(self.value, other)
  33. def __rsub__(self, other):
  34. return int.__rsub__(self.value, other)
  35. def __rmul__(self, other):
  36. return int.__rmul__(self.value, other)
  37. def __rdiv__(self, other):
  38. return int.__rdiv__(self.value, other)
  39. def __rtruediv__(self, other):
  40. return int.__rtruediv__(self.value, other)
  41. def __rfloordiv__(self, other):
  42. return int.__rfloordiv__(self.value, other)
  43. def __rmod__(self, other):
  44. return int.__rmod__(self.value, other)
  45. def __rdivmod__(self, other):
  46. return int.__rdivmod__(self.value, other)
  47. def __rpow__(self, other):
  48. return int.__rpow__(self.value, other)
  49. def __rlshift__(self, other):
  50. return int.__rlshift__(self.value, other)
  51. def __rrshift__(self, other):
  52. return int.__rrshift__(self.value, other)
  53. def __rand__(self, other):
  54. return int.__rand__(self.value, other)
  55. def __rxor__(self, other):
  56. return int.__rxor__(self.value, other)
  57. def __ror__(self, other):
  58. return int.__ror__(self.value, other)
  59. def __iadd__(self, other):
  60. return int.__iadd__(self.value, other)
  61. def __isub__(self, other):
  62. return int.__isub__(self.value, other)
  63. def __imul__(self, other):
  64. return int.__imul__(self.value, other)
  65. def __idiv__(self, other):
  66. return int.__idiv__(self.value, other)
  67. def __itruediv__(self, other):
  68. return int.__itruediv__(self.value, other)
  69. def __ifloordiv__(self, other):
  70. return int.__ifloordiv__(self.value, other)
  71. def __imod__(self, other):
  72. return int.__imod__(self.value, other)
  73. def __ipow__(self, other):
  74. return int.__ipow__(self.value, other)
  75. def __ilshift__(self, other):
  76. return int.__ilshift__(self.value, other)
  77. def __irshift__(self, other):
  78. return int.__irshift__(self.value, other)
  79. def __iand__(self, other):
  80. return int.__iand__(self.value, other)
  81. def __ixor__(self, other):
  82. return int.__ixor__(self.value, other)
  83. def __ior__(self, other):
  84. return int.__ior__(self.value, other)
  85. def __neg__(self):
  86. return int.__neg__(self.value)
  87. def __pos__(self):
  88. return int.__pos__(self.value)
  89. def __abs__(self):
  90. return int.__abs__(self.value)
  91. def __invert__(self):
  92. return int.__invert__(self.value)
  93. def __complex__(self):
  94. return int.__complex__(self.value)
  95. def __int__(self):
  96. return int.__int__(self.value)
  97. def __long__(self):
  98. return int.__long__(self.value)
  99. def __float__(self):
  100. return int.__float__(self.value)
  101. def __oct__(self):
  102. return int.__oct__(self.value)
  103. def __hex__(self):
  104. return int.__hex__(self.value)
  105. def __index__(self):
  106. return int.__index__(self.value)
  107.  
  108. f = Foo(3)
  109. print(f)
  110. print(f.value)
  111. print(f.incr())
  112. print(f.value)
  113. print(f + 2)
  114.  
Success #stdin #stdout 0.04s 9440KB
stdin
Standard input is empty
stdout
<__main__.Foo object at 0xb7299a4c>
3
None
4
6