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

Steven D'Aprano steve at pearwood.info
Tue Jun 30 03:50:04 CEST 2015


On Tue, Jun 30, 2015 at 10:12:42AM +1000, Cameron Simpson wrote:
> On 29Jun2015 16:51, Jonathan Slenders <jonathan at slenders.be> wrote:
> >Could we do that? Is there is reason it's not already a namedtuple?
> >
> >I always forget what the read-end and what the write-end of the pipe is,
> >and I use it quite regularly.
> 
> The ordering is the same as for the default process file descriptors. A 
> normal process has stdin as fd 0 and stdout as fd 1. So the return from 
> pipe() has the read end as index 0 and the write end as fd 1.

Yeah, I always forget which is fd 0 and which is fd 1 too.

Having nice descriptive names rather than using numbered indexes is 
generally better practice, and I don't think there is any serious 
downside to using a namedtuple. A minor enhancement like this shouldn't 
require an extended discussion here on python-ideas.

Jonathan, would you be so kind as to raise an enhancement request on the 
bug tracker? I don't think it's too late for 3.5.


-- 
Steve


More information about the Python-ideas mailing list