[Python-ideas] Default value for input
Steven D'Aprano
steve at pearwood.info
Tue Apr 1 18:16:53 CEST 2014
On Tue, Apr 01, 2014 at 03:21:40PM +0100, Paul Moore wrote:
> 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?).
Sorry, I didn't intend to put down the Windows editing experience, it's
not something I've had much experience with in Python. And you are
right, Python on Linux without readline support is *painful*.
> 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,
Pre-filled buffers are quite common in curses applications like the
mail-client mutt or the editor nano.
I'm hoping for something lightweight and cross-platform, which rules out
curses.
> though, so
> maybe the target audience for this has specialised or unusual
> expectations?
Well, yes, they would be users of console apps who expect user
*friendly* text interfaces instead of the user-hostile ones most
developers write *wink*
> 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').
That's fine for the typical "[Y]/n" one letter inputs that are extremely
common, and I don't have a problem with that. But for longer text, the
inability to modify the default except by retyping the entire thing is a
pretty major failure of the user interface. Imagine if the only way to
get a default value in your GUI or web app's edit field was to put a
label next to it:
Leave the field blank to accept "Something" as the default.
Type a thing here: _______________________________
I wouldn't accept that in my GUI apps, and I don't think that it's
acceptable in console apps either.
> 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.
I obviously don't agree with you, but I appreciate the comments.
Regardless of what happens in 3.5, I'll look at putting something up on
PyPI, although chances are it will require readline support and won't be
platform-independent. That will limit its use drastically.
--
Steven
More information about the Python-ideas
mailing list