[Python-Dev] RE: Windows IO

Fred L. Drake, Jr. fdrake@acm.org
Mon, 17 Mar 2003 17:06:49 -0500

David LeBlanc writes:
 > "isatty" is not documented at all under the Global Modules "sys" entry for
 > Python 2.2.1 documentation (sorry, I thought "PythonDoc" was a recognized
 > name). The following doesn't work:
 > Is isatty a built-in, a function of os only available on Unix, or a function
 > of sys available on all platforms? It appears to be a function in the sys
 > module and so the doc for it should go there?

isatty() is a method of a file object.  It's documented as part of the
file object; see section 2.2.8 of the library reference manual.

 > Under the "os" entry it's:
 > "isatty(fd)
 > Return 1 if the file descriptor fd is open and connected to a tty(-like)
 > device, else 0. Availability: Unix. "
 > I don't see how to create a file() that is connected to stdout without
 > importing sys...? Is there a way? If there is not, than file.isatty() is
 > moot.

Standard output is the file object sys.stdout.

 > So, really, what is the meaning of "64" as the return from
 > sys.stdout.isatty()?

It's a true value.  That's all.


Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation