$ python isatty.py
you are a tty
$ echo foo | python isatty.py
you are not a tty
$
Created
June 3, 2014 14:34
-
-
Save rduplain/e063114479e7470db8d3 to your computer and use it in GitHub Desktop.
Is stdin a tty? Use this to determine whether to provide prompt or just read stdin for input.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
if sys.stdin.isatty(): | |
print('you are a tty') | |
else: | |
print('you are not a tty') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment