On Wed, Oct 26, 2016 at 10:16 PM, Cody Piersall <cody.piers...@gmail.com> wrote: > Isn't that check really just an isatty() check? Or is that not > reliable enough for some reason?
It's not reliable in Windows. There are no tty devices, so the C runtime's implementation of isatty() instead returns true for character devices, which includes the console as well as the NUL device and communication ports. For example: C:\>python -c "import sys; print(sys.stdin.isatty())" < nul True `python < nul` starts the REPL, but it immediately closes because there's nothing to read. On the other hand, reading from COM3 on my current system blocks, and the only way to exit the REPL is to kill the process, such as via Ctrl+Break: C:\>python < com3 Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> ^C The way to check for a console input or screen buffer is by calling GetConsoleMode on the handle. _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/