[Python-ideas] Default value for input
Paul Moore
p.f.moore at gmail.com
Tue Apr 1 16:21:40 CEST 2014
On 1 April 2014 14:01, Steven D'Aprano <steve at pearwood.info> wrote:
> If the platform that Python is running on has no readline/libedit (which
> means Windows), or if the person building Python from source disables
> readline/libedit, the only editing tool which is available is Good Old
> Backspace. But that's better than nothing. I'm not asking for input() to
> duplicate all of readline, just to start with an optional initial value
> in the edit buffer.
Windows has much richer line editing capabilities than "plain old
backspace" - sufficiently so that I end up very frustrated when
working on Unix programs that don't have readline support, because
they are *so* limited (no arrow keys? seriously?).
Ignoring that point, though, pre-filled edit buffers are *extremely*
uncommon on Windows, and I would imagine them being very surprising to
a user. I'm not sure I've ever seen them on Unix either, though, so
maybe the target audience for this has specialised or unusual
expectations? Personally, I'm used to (and comfortable with) the
"Enter a value [12]: " convention where this means that pressing enter
without providing a value gives 12 (and I'd just implement that
manually with if val='': val = '12').
I'm not sure how easy it would be to implement for Windows. I've never
needed it, so I've never looked into it.
-1 on it being a builtin capability of input(). -0 on it being a
separate builtin or stdlib function (mainly because I don't think it's
needed often enough to be worth it). It seems to me it'd be fine as a
package on PyPI, or maybe a recipe.
Paul.
More information about the Python-ideas
mailing list