[Tutor] Please critique my Fraq.py

Tim Peters tim.peters at gmail.com
Sun Jul 25 19:50:39 CEST 2004

[Brian van den Broek, on Dick Moores's IDLE experience]
> I don't know much about msvcrt.getch().

I do <wink>.  The functions in msvcrt call low-level
Microsoft-supplied routines of the same names, and are (of course)
specific to Windows.  They do what the MS routines do, and getch()
works only with MS console windows ("DOS boxes").  It's really a
mistake on the user's part to *try* to use getch() with any other kind
of input device.  IDLE can't do anything about this.

Alas, Python is implemented in C, and C supplies no portable way to
detect the state of the keyboard; "the keyboard" isn't even a concept
in C.  So anyone needing to do this needs to use platform-specific
tricks, and all such tricks work in quirky, platform-specific ways.

If someone cared to volunteer the work, I expect it would be possible
to write a keyboard-sensing function for Tk, and then that could be
used in (but only in) Tk-based programs (like IDLE).

More information about the Tutor mailing list