fork(1) download
  1. import types
  2. def F2(F1):
  3. print 'this is F2.F1: ', F1
  4. def wrapped(func,*a,**k):
  5. print 'this is F2.wrapped.func: ', func, a, k
  6. ### I want to see the variable check here
  7. return F1(func,*a,**k)
  8.  
  9. return wrapped
  10.  
  11.  
  12. def F1(func):
  13. print 'F1.func: ', func
  14. def wrapped(*args, **kwargs):
  15. print "Called with args", args
  16. print "Called with kwargs", kwargs
  17.  
  18. return func(*args, **kwargs)
  19. wrapped=F2(wrapped)
  20. return wrapped
  21.  
  22. F1=F2(F1)
  23.  
  24.  
  25. def test(a,b):
  26. return a + b
  27.  
  28. test=F1(test)
  29.  
  30.  
  31.  
  32. print test(1,2,check=True)
Runtime error #stdin #stdout #stderr 0.01s 7852KB
stdin
Standard input is empty
stdout
this is F2.F1:  <function F1 at 0xb7610ae4>
this is F2.wrapped.func:  <function test at 0xb7610e64> () {}
F1.func:  <function test at 0xb7610e64>
this is F2.F1:  <function wrapped at 0xb7610e2c>
this is F2.wrapped.func:  1 (2,) {'check': True}
Called with args (1, 2)
Called with kwargs {'check': True}
stderr
Traceback (most recent call last):
  File "prog.py", line 32, in <module>
  File "prog.py", line 7, in wrapped
  File "prog.py", line 18, in wrapped
TypeError: test() got an unexpected keyword argument 'check'