[Python-Dev] RE: Windows IO

David LeBlanc whisper@oz.net
Mon, 17 Mar 2003 13:53:55 -0800


> -----Original Message-----
> From: python-dev-admin@python.org [mailto:python-dev-admin@python.org]On
> Behalf Of Tim Peters
> Sent: Monday, March 17, 2003 12:39
> To: David LeBlanc
> Cc: Python-Dev@Python. Org
> Subject: RE: [Python-Dev] RE: Windows IO
>
>
> [David LeBlanc]
> > Have we discovered the mystery of life at last? "True" is 64? :)
> > NOTE: PythonDoc says "isatty" is Unix only.
>
> I don't know what PythonDoc means.  The docs for the file-object method
> isatty (which my examples used) do not say it's Unix only:
>
>     http://www.python.org/doc/current/lib/bltin-file-objects.html
>
> If some other piece of doc contradicts that, please tell
>
>     mailto:python-docs@python.org
>
> or open an SF bug report?
>

I don't have the capability to open an SF bug report.

"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:
J:\>python
Python 2.2.1 (#34, Jul 16 2002, 16:25:42) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> stdout.isatty()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'stdout' is not defined
>>> isatty(stdout)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'isatty' is not defined
>>> isatty(__stdout__)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'isatty' is not defined
>>> import os
>>> os.stdout.isatty()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'stdout'
>>>

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?

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.

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

Dave LeBlanc
Seattle, WA USA