Py3: Terminal or browser output?
Gnarlodious
gnarlodious at gmail.com
Sat Feb 13 15:34:36 EST 2010
On Feb 13, 1:17 pm, "Diez B. Roggisch" wrote:
> However, maybe
>
> if os.isatty(sys.stdout.fileno()):
OK, this works in Python 2:
#!/usr/bin/python
import sys, os
if __name__=="__main__":
if os.isatty(sys.stdout.fileno()):
print "Terminal"
else:
print "Content-type:text/html\n\nBROWSER"
likewise in Python3:
#!/usr/local/bin/python3.1
import sys, os
if __name__=="__main__":
if os.isatty(sys.stdout.fileno()):
print("Terminal")
else:
print("Content-type:text/html\n\nBROWSER")
Thank you, always impressed with the fast help here.
-- Gnarlie
More information about the Python-list
mailing list