fork download
  1. class Counter:
  2. def __init__(self):
  3. self.n = 0
  4.  
  5. def __call__(self):
  6. current = self.n
  7. self.n += 1
  8. return current
  9.  
  10. a = Counter()
  11. b = Counter()
  12. print a(), a()
  13. print b(), b()
  14. print a(), a()
Success #stdin #stdout 0.08s 10840KB
stdin
Standard input is empty
stdout
0 1
0 1
2 3