[Python-ideas] A better interactive prompt
Paul Moore
p.f.moore at gmail.com
Tue Oct 25 17:13:54 EDT 2016
I've seen a lot of syntax proposals recently that are based around
providing better ways of writing "one liner" styles of code.
Typically, the proposals seem to get into trouble because:
1. They duplicate things that can already be done, just not in a
single expression/statement.
2. They are seen as over-terse, which is not generally seen as a good
thing in Python.
However, looking at them from the point of view of someone working at
the interactive prompt, they can seem much more attractive. The
natural unit of interaction at the command line is the single line. To
the extent that (for example) fixing a mistake in a multi-line
construct at the command line is a real pain.
But these limitations are not inherent to Python - they are problems
with the interactive prompt, which is fairly basic[1]. So maybe it's
worth looking at the root issue, how to make the interactive prompt
easier to use[2]?
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? Maybe
even, if IPython is available, allowing the user to configure Python
to use it by default as the interactive prompt (a bit like readline,
but I dislike the way you can't switch off readline integration if
it's installed)? 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.
Thoughts?
Paul
[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).
[2] My apologies to anyone whose proposal was *not* based around
interactive use cases. I'm assuming motives here left, right and
centre, so if what I'm saying isn't what you were intending, that's
fine. Treat this as an unrelated proposal.
More information about the Python-ideas
mailing list