Popen File I/O

D'Arcy J.M. Cain darcy at druid.net
Wed May 27 20:53:16 EDT 2009


On Wed, 27 May 2009 19:39:21 -0500
Eric Pruitt <eric.pruitt at gmail.com> wrote:

> I am creating a file-like interface for Popen. Do I need to return True or
> False for "isatty()"? I am thinking True but I am not familiar with the
> semantics of what defines a tty.

>>> import os
>>> x = os.popen("ls")       
>>> type(x)
<type 'file'>
>>> x.isatty()
False

So what does "creating a file-like interface for Popen" entail?  Popen
already creates a file object.  As for your question, If the object is
reading from a TTY then isatty() is True.  What exactly is your
confusion?

-- 
D'Arcy J.M. Cain <darcy at druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



More information about the Python-list mailing list