Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
is stdin a console
#1
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).
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
Have you tried sys.stdin.isatty() ?
Reply
#3
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.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  stdin input while copying from a process pipe Skaperen 0 1,528 Jul-18-2019, 12:15 AM
Last Post: Skaperen
  Problem with Spyder IDE: Clear console doesn't actually clear the console GalacticStarfish 2 5,621 Sep-03-2017, 09:01 PM
Last Post: dvs1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020