"Dick Moores" <[EMAIL PROTECTED]> wrote

> OK, here's a short script, which runs fine on Windows. What do I add
> to have it run on unix as well?

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 Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld


> #!/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
>
> Dick
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to