isatty() for file-like objects: Implement or not?

Neal Norwitz nnorwitz at gmail.com
Wed Oct 5 06:01:19 CEST 2005


HOWARD GOLDEN wrote:
> The standard documentation for isatty() says:
>
>         "Return True if the file is connected to a tty(-like) device, else
> False. Note: If a file-like object is not associated with a real file,
> this method should not be implemented."
>
> In his book, "Text Processing in Python," David Mertz says: "...
> implementing it to always return 0 is probably a better approach."
>
> My reaction is to agree with Mertz.

I agree, I think the doc is wrong, e.g. StringIO has isatty() which
returns False. I think the doc was probably a thinko (or things have
changed) since Guido checked it in over 3 years ago.

It would be great if you can provide a patch or at least a bug report
on SourceForge.

Thanks,
n




More information about the Python-list mailing list