Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80742

Re: fileno() not supported in Python 3.1

Date 2014-11-14 17:31 +1100
From Cameron Simpson <cs@zip.com.au>
Subject Re: fileno() not supported in Python 3.1
References <85a93u4hpg.fsf@benfinney.id.au>
Newsgroups comp.lang.python
Message-ID <mailman.15810.1415948559.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 14Nov2014 13:52, Ben Finney <ben+python@benfinney.id.au> wrote:
>satishmlmlml@gmail.com writes:
>> How to get file descriptor number for the following:
>> sys.stdin
>> sys.stdout
>> sys.stderr
>
>Why do you need this? What are you intending to do?

In fairness, who cares? It is a basic and reasonable thing to do. I did it only 
last night: I wanted to know if stderr was a tty or pipe, versus a regular 
file, as I wanted to special case some error formatting (loosely speaking, 
default automatic people-friendliness versus log file verbosity).

I know that why people want to do things is important, as they may be choosing 
the wrong approach. But the above question seems very simple and very basic: he 
seems unable to get the OS file descriptor number from the standard streams, 
and this is surprising.

I think he even started the thead with almost a transcript of the failure, and 
backed off the the above abstraction when someone complained.

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

| Alain van der Heide                      |  This is the way the world ends  |
| avdh@dazixco.ingr.com                    |  This is the way the world ends  |
| "The opinions expressed above are mine-  |  This is the way the world ends  |
| mineminemine, and you can't have them."  |  Not with a bang, but with a whi

segmentation fault
core dumped

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: fileno() not supported in Python 3.1 Cameron Simpson <cs@zip.com.au> - 2014-11-14 17:31 +1100

csiph-web