Python Forum

Full Version: is stdin a console
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
is there a portable way to determine if reading stdin will read from the console? i know how to do this in Linux and BSD, but not in MS Windows. a single portable way would be simpler, cleaner, and more pythonic (IMHO) than 2 or 3 OS checks and OS-specific tests for a console (in a function, of course).
Have you tried sys.stdin.isatty() ?
not in MS Windows. does "tty" have a meaning in MS Windows? for POSIX can it be true for a serial port? the library reference doc is not detailed/specific enough to say. i want to know if it is the console. i want False for a serial port even though a user could log in there and run a shell from a connected terminal.