[Python-ideas] Have REPL print less by default
M.-A. Lemburg
mal at egenix.com
Mon Apr 18 03:27:36 EDT 2016
On 18.04.2016 03:04, Franklin? Lee wrote:
> 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.
>
> 1. Limit the output per entered command: If you type into the REPL (AKA
> interactive shell),
>
> list(range(n))
>
> 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.")
>
> Alternatively, have "less"-like behavior.
You should be able to write your own sys.displayhook to accomplish this.
> 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.
>
> 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".
Same here with sys.excepthook.
FWIW: I see your point in certain situations, but don't think the
defaults should be such that you have to enable some variable to see
everything. This would make debugging harder than necessary, since
often enough (following Murphy's law) the most interesting information
would be hidden in some ellipsis.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Experts (#1, Apr 18 2016)
>>> Python Projects, Coaching and Consulting ... http://www.egenix.com/
>>> Python Database Interfaces ... http://products.egenix.com/
>>> Plone/Zope Database Interfaces ... http://zope.egenix.com/
________________________________________________________________________
::: We implement business ideas - efficiently in both time and costs :::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
http://www.egenix.com/company/contact/
http://www.malemburg.com/
More information about the Python-ideas
mailing list