Guest User

Untitled

a guest
Oct 5th, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. import sys
  2.  
  3. def trace_func(frame,event,arg):
  4. value = frame.f_locals["a"]
  5. if value % 2 == 0:
  6. value += 1
  7. frame.f_locals["a"] = value
  8.  
  9. def f(a):
  10. print a
  11.  
  12. if __name__ == "__main__":
  13. sys.settrace(trace_func)
  14. for i in range(0,5):
  15. f(i)
  16.  
  17. 1
  18. 1
  19. 3
  20. 3
  21. 5
  22.  
  23. # Method decorator example
  24. from peak.util.decorators import decorate
  25.  
  26. class Demo1(object):
  27. decorate(classmethod) # equivalent to @classmethod
  28. def example(cls):
  29. print "hello from", cls
  30.  
  31. def foo(x):
  32. if x:
  33. y = 10
  34. return y
  35.  
  36. assert foo(1) == 10
Advertisement
Add Comment
Please, Sign In to add comment