On 2/7/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > What's the best way to get non-blocking input from keyboard w/OS X 10.4? > > while(True) : > if nonBlockInputExists : > break > else : > # continue looping
The 'select' module provides this functionality: import sys, select while select.select([sys.stdin], [], [], 0)[0] == []: continueLooping() However, if you run this from the command line, you'll find that it continues looping until you press return, because the shell doesn't flush stdin until then. I don't think there's much you can do about this for a simple command-line app. However, if all you want is a way to exit your loop without Ctrl-C, and the return key is acceptable, this method works. Cheers, Hamish _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig