Advertisement
Guest User

Untitled

a guest
Apr 9th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. import sys
  2.  
  3. callCount = 0
  4.  
  5. def f2():
  6.     global callCount
  7.     callCount += 1
  8.     try:
  9.         f2()  #This line throws an error
  10.     finally: #except works too
  11.         f2()  #This line does not throw an error!
  12.  
  13.  
  14. for i in range(3, 20):
  15.     sys.setrecursionlimit(i)
  16.     callCount = 0
  17.     print "calls made with recursion limit {}:".format(i),
  18.     try:
  19.         f2()
  20.     except RuntimeError:
  21.         print callCount
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement