[Python-ideas] Make os.pipe() return a namedtuple.

Nathaniel Smith njs at pobox.com
Tue Jun 30 09:11:39 CEST 2015

On Tue, Jun 30, 2015 at 12:03 AM, Chris Angelico <rosuav at gmail.com> wrote:
> On Tue, Jun 30, 2015 at 5:02 PM, Jonathan Slenders <jonathan at slenders.be> wrote:
>> If we use "read" and write as names. It means that often we end up writing
>> code like this:
>> os.write(our_pipe.write, data)
>> os.read(our_pipe.read)
>> Is that ok? I mean, it's not confusing that the os.read is a method, while
>> pip.read is an attribute.
> I'd much rather that than the converse. You always put read with read,
> you always put write with write.

It also appears to be the way that everyone is already naming their variables:


I see returns named "r, w", "rout, wout", "rfd, wfd", "rfd,
self.writepipe", "readfd, writefd", "p2cread, p2cwrite", etc.

Maybe readfd/writefd or read_fileno/write_fileno would be a little
better than plain read/write, both to remind the user that these are
fds rather than file objects and to make the names nouns instead of
verbs. But really read/write is fine too.


Nathaniel J. Smith -- http://vorpus.org

More information about the Python-ideas mailing list