cmd.Cmd asking questions?

Cameron Simpson cs at zip.com.au
Tue Nov 29 22:30:38 EST 2011


On 29Nov2011 13:37, Tim Chase <python.list at tim.thechases.com> wrote:
| On 11/28/11 06:27, Robert Kern wrote:
[...]
| >I actually have a preference for needing to press enter for
| >Y/N answers, too. It's distinctly *less* uniform to have some
| >questions requiring an enter and some not. It can be
| >unpleasantly surprising to the user, too.
| 
| After playing with it, allowing for a default Y/N value seems to
| make it a one-key selection via <enter>, but allow for
| less-surprising behavior as you detail.

As a matter of good practice, I like default responses (especially
yes/no ones) to default to the safer/more-conservative choice, and
generally to default to "no", with the question suitably framed so that
"no" means "safer/more-conservative".

In this way an accidental unthinking <enter> has less chance of doing
damage. What that means depends on context, but I hope you take the point.

(Oh yes, traditionally the default is also capitalised to be evident.)

Example:

  Remove your database now? (y/N)

I would want <enter> to mean "no" here, usually.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

There are old climbers, and there are bold climbers; but there are no old
bold climbers.



More information about the Python-list mailing list