[Python-ideas] A better interactive prompt
Paul Moore
p.f.moore at gmail.com
Wed Oct 26 15:24:52 EDT 2016
On 26 October 2016 at 18:25, Nick Coghlan <ncoghlan at gmail.com> wrote:
> The built-in REPL serves two quite divergent use cases, and I think
> we're well past the point where we can't readily support both use
> cases with a single implementation:
>
> - a minimalist interactive environment, that is *always* present, even
> if parts of the interpreter (most notably the import system) aren't
> working or have been deliberately disabled
> - a day-to-day working environment for Python developers
>
> The prevalence of the latter use case then leads to it also being used
> as a tool for introducing new developers to Python.
Thinking a little further about this, I think the reason I don't use
IPython more, is because my muscle memory types "python" (or more
often, "py") when I want an interactive prompt. And I do that for the
reason you mention - it's always there.
So I think that it would be really useful to be able to plug in a new
REPL, when it's available. This has a number of benefits:
1. We don't need to worry about incorporating any complex REPL code
into Python. The default REPL can remain simple.
2. Users can choose their preferred REPL, core Python doesn't have to
get involved in UI decisions.
The downside, of course, is that the default behaviour is inconsistent
- new users could attend a course where IPython was preinstalled, but
then struggle when back at the office because no-one told them how to
set it up.
> One possible path towards improving the situation might be to look at
> the PyPy REPL (which is presumably implemented in RPython) and see if
> that would be suitable for incorporation into CPython as a frozen
> module (perhaps with some modifications). That has the advantage of
> making the REPL much easier to iterate on (since you can use the
> non-frozen version for development), while still making it available
> at runtime as part of the core Python binary.
I've never used the PyPy REPL, so I can't speak to its features. But
this seems to me to simply be a matter of incremental improvement to
the standard REPL, That's no bad thing, but as you pointed out at the
start, we can't support both of our use cases with a single
implementation, so this doesn't solve the fundamental problem - it
merely alters the breakpoint at which people need to learn not to fire
up the REPL, but rather to start up IPython, or bpython, or their
environment of choice. And it doesn't do much for people who (like me)
type "python" instinctively, and only realise they needed something
better part way through their session.
Paul
More information about the Python-ideas
mailing list