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

Cameron Simpson cs at zip.com.au
Tue Jun 30 04:05:29 CEST 2015


On 30Jun2015 11:50, Steven D'Aprano <steve at pearwood.info> wrote:
>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.

Shrug. I use the rationale above. stdin==0 is extremely easy to remember. 
However, I have no cogent objection to a named tuple myself.

>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.

But... what shall we call the attributes? Sure an extended bikeshed is required 
here:-)

Cheers,
Cameron Simpson <cs at zip.com.au>

I will be a speed bump on the information super-highway.
        - jvogel at math.rutgers.edu (jeff vogel)


More information about the Python-ideas mailing list