How can I tell the file (or tty) that is attached to my stdios?
Something like:
>>> import sys
>>> print sys.stdin.__path__
'/dev/tty1'
>>>
I could look in proc:
import os, sys
os.readlink('/proc/self/fd/%s' % sys.stdin.fileno())
But seems like there should be a builtin way?
Got it!
It
raisesOSError: [Errno 22] Invalid argumentif stdin isn’t a TTY; but thats easy enough to test for withisatty()