Breaking out of a while loop with a key press?

Bengt Richter bokr at oz.net
Tue Apr 1 05:49:43 EST 2003


On Tue, 1 Apr 2003 07:59:44 +0100, "Richard" <richardd at hmgcc.gov.uk> wrote:

>Hi guys,
>
>Thank you all for your suggestions. I'm sorry my question was a bit
>ambiguous with regard to the 'console window' reference. I was in fact
>referring to a Win2K Command Prompt (cmd.exe).
>
>I will try catching the KeyboardInterrupt exception and check that I have no
>bare 'except's anywhere that could be catching this for me.
>
Note that catching the exception means allowing the exception to interrupt
wherever in your loop execution may be, so you can not expect such a loop exit
to give you a final complete loop execution. See suggestions (mine and
others) for using signal handlers to accomplish orderly loop termination
based on modifying a while loop condition from a signal handler (which
returns to continue execution of the loop where interrupted).

Regards,
Bengt Richter




More information about the Python-list mailing list