[Python-ideas] Have REPL print less by default

Ben Finney ben+python at benfinney.id.au
Sun Apr 17 21:42:57 EDT 2016

"Franklin? Lee"
<leewangzhong+python at gmail.com> writes:

> 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.

For that specific example, when I run it, the output is quite short:

    $ python3

    >>> n = 10**10
    >>> list(range(n))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>

I take the point though: some objects have a very long ‘repr’ 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.")

Perhaps you want a different “print the interactive-REPL-safe text
representation of this object” function, and to have the interactive
REPL use that new function to represent objects.

 \      “I am too firm in my consciousness of the marvelous to be ever |
  `\       fascinated by the mere supernatural …” —Joseph Conrad, _The |
_o__)                                                     Shadow-Line_ |
Ben Finney

More information about the Python-ideas mailing list