RuntimeError 'maximum recursion depth exceeded'

Ray Smith ray at rays-web.com
Sat Nov 15 07:08:32 EST 2003


Georgy Pruss wrote:
> Sometimes I get this error.
> E.g.
> 
> 
>>>>sum = lambda n: n<=1 or n+sum(n-1) # just to illustrate the error
>>>>sum(999)
> 
> 499500
> 
>>>>sum(1000)
> 
> ...........
> RuntimeError: maximum recursion depth exceeded
> 
> Is there any way to set a bigger stack in Python?
> 
> G-:

See

sys.getrecursionlimit(), and
sys.setrecursionlimit(limit)

doco at:

http://python.org/doc/current/lib/module-sys.html

a quick search of the doco or the newsgroup archive at:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&group=comp.lang.python

would have found the answer.

Regards,

Ray Smith





More information about the Python-list mailing list