[Python-ideas] Have REPL print less by default
Joseph Martinot-Lagarde
contrebasse at gmail.com
Tue Apr 19 06:01:49 EDT 2016
Franklin? Lee <leewangzhong+python at ...> writes:
> 2. Only print a few parts of the stack trace. In particular, for a
recursive or mutually recursive function, if the error was due to maximum
recursion (is this reasonably distinguishable? the error is
`RuntimeError('maximum recursion depth exceeded')`), try to print each
function on the stack once each.
> - If a function appears more than once in a row, show it once, with the
note, "(and X recursive calls)".
> - If functions otherwise appears more than once (usually by mutual
recursion?), and there is a run of them, list them as, "(Mutual recursion:
'x' (5 times), 'y' (144 times), 'z' (13 times).)".
I don't know about the other ideas, but simplifying the output of recursion
errors would be very useful. 990 repeats of the exact same lines add no
value at all, the user being an expert or a beginner.
Something like this is very clear in my mind:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/script.py", line 10, in f
f()
File "/home/user/script.py", line 10, in f
f()
...
File "/home/user/script.py", line 10, in f (994 repeats)
f()
...
File "/home/user/script.py", line 10, in f
f()
File "/home/user/script.py", line 10, in f
f()
RecursionError: maximum recursion depth exceeded
More information about the Python-ideas
mailing list