Fork me on GitHub

Fixing error - maximum recursion depth reached

August 31, 2013

Hi there folks. In this post I am going to teach you how to increase the recursion depth in python. Most of us at some time get this error :

RuntimeError: maximum recursion depth exceeded

If you want to fix this error just increase the default recursion depth limit but how to do it ? Just import the sys module in your script and in the beginning of the script type this :

sys.setrecursionlimit(1500)

This will increase the default limit to 1500. For the record the default limit is 1000. I hope that you found this post useful. Do share this on facebook and twitter and stay tuned for our next post.



Comments