fork download
  1. class Example:
  2. def __init__(self, name):
  3. self.name = name
  4. def __repr__(self):
  5. return f'Example({self.name!r})'
  6. def __add__(self, other):
  7. print(f"Evaluating {self} + {other}")
  8. return Example('addition result')
  9. def __mul__(self, other):
  10. print(f"Evaluating {self} * {other}")
  11. return Example('multiplication result')
  12.  
  13. a = Example('a')
  14. b = Example('b')
  15. c = Example('c')
  16. d = Example('d')
  17.  
  18. a + b + c * d
Success #stdin #stdout 0.02s 9080KB
stdin
Standard input is empty
stdout
Evaluating Example('a') + Example('b')
Evaluating Example('c') * Example('d')
Evaluating Example('addition result') + Example('multiplication result')