fork download
  1. import functools
  2.  
  3. x = 0
  4.  
  5. def wrapper(fn):
  6. @functools.wraps(fn)
  7. def wrapped(*args, **kwargs):
  8. global x
  9. x += 10
  10. print(x)
  11. return fn(*args, **kwargs)
  12. return wrapped
  13.  
  14. def f(x): return 2
  15. def g(x): return 3
  16.  
  17. f = wrapper(f)
  18. g = wrapper(g)
  19. f(2)
  20. g(3)
Success #stdin #stdout 0s 9024KB
stdin
Standard input is empty
stdout
10
20