getch() of Turbo C in Python?
Bjorn Pettersen
BPettersen at NAREX.com
Thu Jun 7 15:33:53 EDT 2001
> From: Anurag Ved [mailto:anuragved at vsnl.com]
>
> Hi all,
> I am using the Python interpreter under Windows. When I execute a
> Python script, the console window that opens up closes immediately
> after the program terminates, leaving me no time to observe the
> output. One solution is to append the program with
>
> raw_input('')
>
> But, this is certainly not elegent and moreover it requires the user
> to press 'enter' rather than the preferred option of 'any key'.
>
> Is there something similar to the getch() function of Turbo C which
> reads just one key from <stdin> and returns immediately?
import msvcrt
msvcrt.getch()
-- bjorn
More information about the Python-list
mailing list