fork download
  1. import sys
  2.  
  3. counter = 0
  4.  
  5. def pr(*args):
  6. global counter
  7. counter += 1
  8. print("pr has been called %d time%s already" % (counter, counter > 1 and "s" or ""))
  9.  
  10. sys.settrace(pr)
  11.  
  12. min(10,5)
  13. max(10,5)
  14. min(10,5)
  15. max(10,5)
  16.  
  17. def decor(func):
  18. return func
  19.  
  20. l = lambda x,y: 5
  21.  
  22. @decor
  23. def func():
  24. print("func called")
  25.  
  26. func()
  27.  
  28. print("before class definition")
  29.  
  30. class A():
  31. def __init__(self):
  32. print("A init called")
  33.  
  34. def m(self):
  35. print("A method called")
  36.  
  37. class B():
  38. def m(self):
  39. print("B method called")
  40.  
  41. def __repr__(self):
  42. return "<__main__.B object at " + hex(id(a) + 128) + ">"
  43.  
  44. print("after class definition")
  45.  
  46. a = A()
  47. print("instance of A created")
  48. a.m()
  49.  
  50. b = B()
  51. print("instance of B created")
  52. b.m()
  53.  
  54. print("repr?")
  55.  
  56. print(a)
  57. print(b)
Success #stdin #stdout 0.02s 9984KB
stdin
Standard input is empty
stdout
pr has been called 1 time already
pr has been called 2 times already
func called
before class definition
pr has been called 3 times already
pr has been called 4 times already
after class definition
pr has been called 5 times already
A init called
instance of A created
pr has been called 6 times already
A method called
instance of B created
pr has been called 7 times already
B method called
repr?
<__main__.A object at 0xb72cffac>
pr has been called 8 times already
<__main__.B object at 0xb72d002c>