Processing a key pressed in Python 3.6

Virgil Stokes vs at it.uu.se
Tue Jan 23 13:50:57 EST 2018


I would appreciate help on finding a solution to following problem. This 
is the general structure of the "problem" code:

> while True
>     # Get some data from the web and process it
>     ...
>     ...
>     # Write these data to a file
>     ...
>     ...
>     # Check if a_key has been pressed in the command window
>     ...
>     ...
>     if a_key_pressed:
>         # Perform some pre-termination tasks
>         ...
>         ...
>         # Close the output data file
>         ...
>         ...
>         raise SystemExit('Exit')

I am running the code with Python 3.6 on a windows 10 platform. I have 
tried many approaches (mainly those posted on stackoverflow) but I have 
yet to find an approach that works for this structure.

Note:
   1) The code is executed in the windows 10 command window
   2) I am not using wxPython, IDLE, or pyGame in this application.
   3) The time to get the data, process it and write it to a file can
      take from 0.5 sec to 1.5 sec
   4) The key hit need not be echoed to the command window





More information about the Python-list mailing list