fork download
  1. def counter(func):
  2. i = [0, ]
  3.  
  4. def _f(*args):
  5. i[0] += 1
  6. print(i[0])
  7. return func(*args)
  8.  
  9. return _f
  10.  
  11.  
  12. @counter
  13. def a(x):
  14. return x
  15.  
  16.  
  17. print(a('hey'))
  18. print(a('hey'))
  19. print(a('heuhe'))
  20. print(a('dsds'))
Success #stdin #stdout 0.02s 8688KB
stdin
Standard input is empty
stdout
1
hey
2
hey
3
heuhe
4
dsds