[Python-ideas] Option of running shell/console commands inside the REPL

Oleg Broytman phd at phdru.name
Sat Feb 2 08:21:45 EST 2019


On Sat, Feb 02, 2019 at 02:10:06PM +1100, Steven D'Aprano <steve at pearwood.info> wrote:
> On Fri, Feb 01, 2019 at 09:31:21PM +0100, Oleg Broytman wrote:
> 
> >    Python REPL is missing the following batteries:
> > 
> > * Persistent history;
> 
> On Linux/Unix systems, that has been available for about 18+ years, 
> since the rlcompleter module was introduced in Python 2.0:
> 
> https://docs.python.org/release/2.0/lib/module-rlcompleter.html
> 
> It's been automatically enabled for more than six years:
> 
> https://hg.python.org/cpython/rev/d5ef330bac50

   I've configured my own .pythonrc long before that so I missed that
it's now finally enabled. Thanks for pointing this out.

> Windows is another story.
> 
> 
> > * Syntax highlighting;
> 
> bpython provides syntax highlighting in the REPL, but I've never seen 
> the point. In an editor, perhaps, but why bother in the REPL?
> 
> https://bpython-interpreter.org/
> 
> So does DreamPie:
> 
> http://www.dreampie.org/
> 
> > * Clear separation (using, for example, different colors)
> >   between input, output and errors;
> 
> Input always starts with a prompt;

   And I have a different color just for prompt.

> exception tracebacks always start 
> with the line "Traceback..."; other errors are generally not 
> programmatically distinguishable from non-errors.
> 
> One could modify the displayhook and excepthook to deal with the usual 
> cases, but colour codes are not just platform-specific but console- 
> specific.
> 
> https://docs.python.org/3.5/library/sys.html#sys.displayhook
> 
> https://docs.python.org/3.5/library/sys.html#sys.excepthook
> 
> 
> > * Paging of very long output/errors.
> 
> I don't know how I feel about that. Now that Python shrinks long 
> tracebacks filled with identical lines, I'm not sure that this is so 
> important or desirable.
> 
> >>> import sys
> >>> sys.setrecursionlimit(30)
> >>> def spam():
> ...     spam()
> ...
> >>> spam()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "<stdin>", line 2, in spam
>   File "<stdin>", line 2, in spam
>   File "<stdin>", line 2, in spam
>   [Previous line repeated 26 more times]
> RecursionError: maximum recursion depth exceeded

> -- 
> Steve

Oleg.
-- 
    Oleg Broytman            https://phdru.name/            phd at phdru.name
           Programmers don't die, they just GOSUB without RETURN.


More information about the Python-ideas mailing list