fork download
  1.  
  2. class MyInt:
  3. def __init__(self, value):
  4. self.value = value
  5. self.posflag = False
  6. def __pos__(self):
  7. if self.posflag:
  8. self.posflag = not self.posflag
  9. self.value += 1
  10. return self.value
  11. else:
  12. self.posflag = not self.posflag
  13. return self
  14.  
  15. a = MyInt(10)
  16. print(++a) # 11
  17.  
Success #stdin #stdout 0.03s 9348KB
stdin
Standard input is empty
stdout
11