Py3: Terminal or browser output?
Gnarlodious
gnarlodious at gmail.com
Sat Feb 13 15:34:36 EST 2010
More information about the Python-list mailing list
Sat Feb 13 15:34:36 EST 2010
- Previous message (by thread): Py3: Terminal or browser output?
- Next message (by thread): Py3: Terminal or browser output?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message (by thread): Py3: Terminal or browser output?
- Next message (by thread): Py3: Terminal or browser output?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list