[Python-ideas] A better interactive prompt
Steven D'Aprano
steve at pearwood.info
Wed Oct 26 20:49:18 EDT 2016
On Tue, Oct 25, 2016 at 10:13:54PM +0100, Paul Moore wrote:
> I've seen a lot of syntax proposals recently that are based around
> providing better ways of writing "one liner" styles of code.
[...]
> However, looking at them from the point of view of someone working at
> the interactive prompt, they can seem much more attractive.
I spend a lot of time working at the interactive prompt, and I don't
agree that these proposals seem more attractive for that reason.
[...]
> But these limitations are not inherent to Python - they are problems
> with the interactive prompt, which is fairly basic[1].
It really isn't that basic. But you know that, as your footnote points
out ;-)
> So maybe it's
> worth looking at the root issue, how to make the interactive prompt
> easier to use[2]?
I'm completely happy with moves to make the REPL better, but it won't
make a lick of difference. Some people simply like one-liners, and won't
be happy until they can write an entire application as a single, short
one-liner. Look at the popularity of Perl. Or for that matter, APL. Some
people are more concerned with minimizing the amount of vertical space a
chunk of code users, or horizontal space, or keystrokes.
Of course we *should* care about these things! We may disagree about the
relative weight we give to these factors, not that they are important.
There's always going to be tension between those who want to save just
one more line and those who think oh no not another cryptic symbol to
memorize.
I think the Python community has managed to fit itself into a nice
position in the "Goldilocks Zone" of syntax: not too much, not too
little. But there's always going to be disagreements over precisely how
much is too much, and a better REPL isn't going to stop that.
There's space for lots of languages in the world, and I'm glad there is
room for those who love Perl one-liners to write Perl. I just don't want
them turning Python into a second-rate Perl :-)
> But that's something of a solved problem. IPython offers a rich
> interactive environment, for people who find the limitations of the
> standard interactive prompt frustrating. Would it be worth the
> standard Python documentation promoting IPython for that role?
IPython is no panacea. It's too rich, too powerful for many users. Not
everybody wants to replace their regular shell (say, bash) with IPython.
And some of us don't like IPython's [in] [out] prompts and all those
unnecessary blank lines.
We *should* promote third-party REPLs like IPython and BPython as
alternatives for power users.
http://bpython-interpreter.org/
But we shouldn't use that as an excuse to neglect the standard REPL,
which is pretty good. For my uses, there's not a lot that I think is
missing: Python's REPL on Linux with readline is pretty darn good.
Perhaps the main feature that I miss is this:
http://bugs.python.org/issue22228
> Maybe
> even, if IPython is available, allowing the user to configure Python
> to use it by default as the interactive prompt
I feel that is more something that people should configure their
personal desktop or shell environment for, e.g. by setting up an alias.
> (a bit like readline,
> but I dislike the way you can't switch off readline integration if
> it's installed)?
This comment surprises me. To me, that's like saying "I dislike the way
you can't switch off breathing" -- readline is almost indispensible. The
REPL experience without line editing (apart from backspace) and history
is *horrible*. Why would you want to switch it off?
My hobby is collecting old Python versions, some of which are old enough
that they don't support readline. (Or were never configured correctly
for readline.) I don't use them often, but when I do, the experience is
painful.
> Ideally, if IPython was more readily available, fewer
> users would be frustrated with Python's existing multi-line
> constructs. And those that were, would have the option of looking into
> custom IPython magic commands, before being forced to request language
> changes.
I don't think that the interactive prompt is what drives these requests.
I think they are usually driven by differences in the weight people give
to certain desirable characteristics of code.
Some people have a higher tolerance towards terse special syntax; some
people have a higher tolerance towards verbosity. Neither is completely
wrong (although I feel that COBOL-like verbosity is probably less
harmful than extremely terse languages like specialist code-golf
languages). There will always be disagreements.
> [1] On the other hand, the interactive prompt is a huge part of what
> makes Python so great - these days, when I have to code in languages
> that don't have an interactive prompt, it drives me nuts. And even
> those that do, typically don't have one as good as Python's (in spite
> of the fact that this whole mail is about needing to improve the
> Python REPL).
Exactly.
--
Steve
More information about the Python-ideas
mailing list