Minimising stack trace

Ned Batchelder ned at nedbatchelder.com
Fri May 15 15:04:27 EDT 2015


On Friday, May 15, 2015 at 2:50:12 PM UTC-4, Cecil Westerhof wrote:
> While playing with recursion I get:
>     RuntimeError: maximum recursion depth exceeded in comparison
> 
> But then I get a very long stack trace. Is there a way to make this a
> lot shorter. Now I 'lose' interesting information because of the
> length of the stack trace.

There isn't a way to shorten the stack trace.  If you are losing
information at the top because of your terminal window, you can
likely increase the number of lines it will keep for you.

Another option is to reduce the maximum stack depth, so that it
is exceeded sooner, which produces shorter stack traces:

    import sys;
    sys.setrecursionlimit(50)


--Ned.



More information about the Python-list mailing list