[Tutor] Looking for suggestions for improving chessTimer.py code
Kent Johnson
kent37 at tds.net
Mon Oct 29 11:44:25 CET 2007
Dick Moores wrote:
> OK, here's a short script, which runs fine on Windows. What do I add
> to have it run on unix as well?
>
> #!/usr/bin/env python
> #coding=utf-8
>
> try:
> # windows or dos
> import msvcrt
> while True:
> if msvcrt.kbhit():
> key = msvcrt.getch()
> if key == "h":
> print "Hello, World!"
> break
> print "Bye, World!"
>
> except ImportError:
> # assume unix
> import tty, termios
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/134892
Kent
More information about the Tutor
mailing list