cmd.Cmd asking questions?

Robert Kern robert.kern at gmail.com
Wed Nov 30 05:05:52 EST 2011


On 11/30/11 3:30 AM, Cameron Simpson wrote:
> 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.

I would also add that if you can, try to make it such that the user can go back 
and change their mind before actually doing anything. In the "wizard" scenario 
that the OP describes, it is frequently the case that you are going to ask a 
number of questions first before actually doing anything rather than doing 
something after each question. I don't think that letting the user go back a 
previous question is particularly common, and every interface for it that I can 
think of off the top of my head seems awkward, but I think it deserves some 
thought. At the very least, what you can do is collect all of the answers, show 
them to the user at the end and ask if there is anything the user wants to 
change before continuing.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list