[Tutor] msvcrt or else?

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Thu Mar 27 18:18:01 2003


> >def  hello():
> >    n = raw_input('your name?>>')
> >    if n == 'q':
> >        sys.exit()
> >    print 'hello ' + n
> >    hello()
> >
> >How to replace "if" conditional with single press on "Esc" key?
> >Would it be the same solution in unix?
>
> You have to make do with whatever specialized input methods are
> available for your platform, which (unfortunately) means writing
> platform-specific (or at very least platform-aware) code.


Here you go:

    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/134892

I believe that the escape character is the same on Windows and Unix
systems ('\x1b'), but, unfortunately, I don't have a Windows machine to
test this on.



Hope this helps!