[Tutor] Requesting input, waiting a fixed time

Gerrit Holl gerrit@nl.linux.org
Wed, 1 Mar 2000 20:35:27 +0100

<quote name="Hicks,David P.(NXI)" date="951905931" email="David.Hicks@cna.com">
> Is there a "standard" Python way of accomplishing this?:
> Ask the user to answer "Yes" or "No"
> If he/she responds, process the answer.
> If there is no response for 3 minutes, assume the answer is "Yes" and
> process.
> Any hints would be appreciated. Thanks.

Use the raw_input function:


   raw_input ([prompt])
          If the prompt argument is present, it is written to standard
          output without a trailing newline. The function then reads a
          line from input, converts it to a string (stripping a trailing
          newline), and returns that. When EOF is read, EOFError is
          raised. Example:

>>> s = raw_input('--> ')
--> Monty Python's Flying Circus
>>> s
"Monty Python's Flying Circus"

          If the readline module was loaded, then raw_input() will use it
          to provide elaborate line editing and history features.



Plis korekt eni ingglisj joe encounter in mai imeel meeasj!
-----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com
Version: 3.12
GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE?
Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y