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

Ben Finney ben+python at benfinney.id.au
Tue Jun 30 04:10:22 CEST 2015

Steven D'Aprano <steve at pearwood.info> writes:

> 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

I definitely prefer to use, and promote, the explicit names “stdin”,
“stdout”, and “stderr” rather than the file descriptor numbers.

On the point of confusing them though: I find it easy enough to remember
that the two streams for output stay together, and the input one comes
first at 0.

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

+1, let's just get the standard names there as attributes of a

One more set of magic numbers to relegate to implementation detail,
encapsulated where they belong!

 \         Fry: “Take that, poor people!”  Leela: “But Fry, you’re not |
  `\     rich.”  Fry: “No, but I will be someday, and then people like |
_o__)                                  me better watch out!” —Futurama |
Ben Finney

More information about the Python-ideas mailing list