<p dir="ltr">Two different (probably radical) ideas, with the same justification: reduce often-useless output in the REPL, which can flood out terminal history and overwhelm the user.<br></p>
<p dir="ltr">1. Limit the output per entered command: If you type into the REPL (AKA interactive shell),</p>
<p dir="ltr"> list(range(n))</p>
<p dir="ltr">and you forgot that you set n to 10**10, the interpreter should not print more than a page of output. Instead, it will print a few lines ("... and approximately X more lines"), and tell you how to print more. (E.g. "Call '_more()' for more. Call '_full()' for full output.")</p>
<p dir="ltr">Alternatively, have "less"-like behavior.<br></p>
<p dir="ltr">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.</p>
<p dir="ltr">Again, there should be a message telling you how to get the full stacktrace printed. EXACTLY how, preferably in a way that is easy to type, so that a typo won't cause the trace to be lost. It should not use `sys.something()`, because the user's first few encounters with this message will result in, "NameError: name 'sys' is not defined".</p>
<p dir="ltr">A few possible rules to reduce stacktrace size:<br>
- Always show the last (top) frame(?).<br>
- Hide any other stdlib funcs directly below (above) it.<br>
- If a function appears more than once in a row, show it once, with the note, "(and X recursive calls)".<br>
- 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).)".<br></p>
<p dir="ltr">These two behaviors and their corresponding functions could go into a special module which is (by default) loaded by the interactive shell. The behaviors can be turned off with some command-line verbosity flag, or tuned with command-line parameters (e.g. how many lines/pages to print).<br></p>
<p dir="ltr">Justification:</p>
<p dir="ltr"> - Excessive output floods the terminal window. Some terminals have a limit on output history (Windows *defaults* to 300 lines), or don't let you scroll up at all (at least, my noob self couldn't figure it out when I did get flooded).</p>
<p dir="ltr"> - Students learning Python, and also everyone else using Python, don't usually need 99% of a 10000-line output or stack trace.</p>
<p dir="ltr"> - People who want the full output are probably advanced users with, like, high-limit or unlimited window size, and advanced users are more likely to look for a verbosity flag, or use a third-party REPL. Default should be newbie friendly, because advanced users can work around it.<br></p>
<p dir="ltr">Thoughts? Even if the specific proposals are unworkable, is limiting REPL output (by default) a reasonable goal?</p>