[Tutor] Looking for suggestions for improving chessTimer.py code

Dick Moores rdm at rcblue.com
Mon Oct 29 16:27:48 CET 2007


At 01:13 AM 10/27/2007, Alan Gauld wrote:
>Take a look at my Event Driven programming topic. It contains a
>simple key echo program using msvcrt and instructions for Linux
>users to convert it to use curses.
>
> From that you should be able to create a dual platform version.

Alan, I'm afraid I wasn't able to, using 
<http://www.freenetpages.co.uk/hp/alan.gauld/>. Especially because I 
couldn't test what I was coming up with. Could you do it for me, for 
this tiny script?

===============================
#!/usr/bin/env python
#coding=utf-8
import msvcrt
while True:
     if msvcrt.kbhit():
         key = msvcrt.getch()
         if key == "q":
                break
         elif key == "h":
                print "Hello"
         elif key == "b":
                print "Bye"
===============================

Dick




More information about the Tutor mailing list