Skip to content

Instantly share code, notes, and snippets.

@cou929
Created December 9, 2012 03:30
Show Gist options
  • Save cou929/4243210 to your computer and use it in GitHub Desktop.
Save cou929/4243210 to your computer and use it in GitHub Desktop.
sys.stdin.isatty() の確認
$ python -c 'import sys; print dir(sys.stdin)'
['__class__', '__delattr__', '__doc__', '__enter__', '__exit__', '__format__', '__getattribute__', '__hash__', '__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'close', 'closed', 'encoding', 'errors', 'fileno', 'flush', 'isatty', 'mode', 'name', 'newlines', 'next', 'read', 'readinto', 'readline', 'readlines', 'seek', 'softspace', 'tell', 'truncate', 'write', 'writelines', 'xreadlines']
$ python -c 'import sys; print sys.stdin.isatty()'
True
$ echo | python -c 'import sys; print sys.stdin.isatty()'
False
$ python -c 'import sys; print sys.stdin.isatty()' < ~/.bashrc
False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment