Breaking out of a while loop with a key press?

Richard richardd at hmgcc.gov.uk
Tue Apr 1 01:59:44 EST 2003


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.

Thanks for your help...

Richard

"Richard" <richardd at hmgcc.gov.uk> wrote in message
news:3e885ad5 at mail.hmgcc.gov.uk...
> Hi,
>
> Can anyone suggest a simple way of detecting a key press and existing the
> program? I have a program which at the moment uses a while True:
statement.
> However this is not ideal as I have to close down the console window to
> exist the program. Can anyone tell me the proper way of doing this? So
that
> a CTRL-C, for example, can quit the program correctly?
>
> Cheers
>
> Richard
>
>






More information about the Python-list mailing list