Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80723 > unrolled thread
| Started by | satishmlmlml@gmail.com |
|---|---|
| First post | 2014-11-13 15:40 -0800 |
| Last post | 2014-11-14 18:42 +1100 |
| Articles | 6 — 6 participants |
Back to article view | Back to comp.lang.python
Bad file descriptor satishmlmlml@gmail.com - 2014-11-13 15:40 -0800
Re: Bad file descriptor sohcahtoa82@gmail.com - 2014-11-13 15:43 -0800
Re: Bad file descriptor Ben Finney <ben+python@benfinney.id.au> - 2014-11-14 10:56 +1100
Re: Bad file descriptor Roy Smith <roy@panix.com> - 2014-11-13 19:41 -0500
Re: Bad file descriptor Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-14 05:17 +0000
Re: Bad file descriptor Cameron Simpson <cs@zip.com.au> - 2014-11-14 18:42 +1100
| From | satishmlmlml@gmail.com |
|---|---|
| Date | 2014-11-13 15:40 -0800 |
| Subject | Bad file descriptor |
| Message-ID | <442861d9-4280-4222-9084-f626a7782161@googlegroups.com> |
import os os.write(1, b'Hello descriptor world\n') OSError: Bad file descriptor How to give a file descriptor number to this function? How to get a file descriptor number?
[toc] | [next] | [standalone]
| From | sohcahtoa82@gmail.com |
|---|---|
| Date | 2014-11-13 15:43 -0800 |
| Message-ID | <d22be677-a286-4a63-a791-611fb91c2989@googlegroups.com> |
| In reply to | #80723 |
On Thursday, November 13, 2014 3:40:50 PM UTC-8, satish...@gmail.com wrote: > import os > os.write(1, b'Hello descriptor world\n') > OSError: Bad file descriptor > > How to give a file descriptor number to this function? How to get a file descriptor number? http://bit.ly/1zRWHyq
[toc] | [prev] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2014-11-14 10:56 +1100 |
| Message-ID | <mailman.15802.1415923204.18130.python-list@python.org> |
| In reply to | #80723 |
satishmlmlml@gmail.com writes:
> import os
> os.write(1, b'Hello descriptor world\n')
> OSError: Bad file descriptor
It works fine for me::
>>> import os
>>> os.write(1, b'Hello descriptor world\n')
Hello descriptor world
23
You don't say which Python, or which version, you're using. In the
absence of different information, most of us will assume the latest
stable release of CPython. Currently, that is CPython 3.4.
--
\ “I am too firm in my consciousness of the marvelous to be ever |
`\ fascinated by the mere supernatural …” —Joseph Conrad, _The |
_o__) Shadow-Line_ |
Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2014-11-13 19:41 -0500 |
| Message-ID | <roy-050828.19405213112014@news.panix.com> |
| In reply to | #80731 |
In article <mailman.15802.1415923204.18130.python-list@python.org>,
Ben Finney <ben+python@benfinney.id.au> wrote:
> satishmlmlml@gmail.com writes:
>
> > import os
> > os.write(1, b'Hello descriptor world\n')
> > OSError: Bad file descriptor
>
> It works fine for me::
>
> >>> import os
> >>> os.write(1, b'Hello descriptor world\n')
> Hello descriptor world
> 23
>
> You don't say which Python, or which version, you're using. In the
> absence of different information, most of us will assume the latest
> stable release of CPython. Currently, that is CPython 3.4.
I don't think this has anything to do with which version of Python he's
using. I think all that's happening is (for some unknown reason), fd 1
is closed before his program runs. You can demonstrate this, for
example, in bash:
$ cat hello.py
import os
os.write(1, b'Hello descriptor world\n')
$ python hello.py
Hello descriptor world
$ 1<&- python hello.py
Traceback (most recent call last):
File "hello.py", line 2, in <module>
os.write(1, b'Hello descriptor world\n')
OSError: [Errno 9] Bad file descriptor
You owe the Oracle 5 minutes of his life back and a cookie for making
him read enough of the bash manual to figure out the syntax to tell it
to close a descriptor.
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-11-14 05:17 +0000 |
| Message-ID | <mailman.15807.1415942240.18130.python-list@python.org> |
| In reply to | #80723 |
On 13/11/2014 23:40, satishmlmlml@gmail.com wrote: > import os > os.write(1, b'Hello descriptor world\n') > OSError: Bad file descriptor > > How to give a file descriptor number to this function? How to get a file descriptor number? > I suggest getting your cheque book out and paying for the advice you so desperately need. Or follow the advice already given about asking smart questions. Or RTFM. Or simply go away. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Cameron Simpson <cs@zip.com.au> |
|---|---|
| Date | 2014-11-14 18:42 +1100 |
| Message-ID | <mailman.15815.1415952546.18130.python-list@python.org> |
| In reply to | #80723 |
On 13Nov2014 15:40, satishmlmlml@gmail.com <satishmlmlml@gmail.com> wrote:
>import os
>os.write(1, b'Hello descriptor world\n')
>OSError: Bad file descriptor
>
>How to give a file descriptor number to this function? How to get a file descriptor number?
Wow, this must be at least the 4th post of the same question.
It now occurs to me that a newer Python won't help you.
Are you running this at a command prompt?
Or are you running this in some IDE?
The reason I ask this question is that at a command prompt, the above would
probably work.
In short, please provide more context. What OS? What version of Python? What
environment (command prompt, IDE (which one?), a standalone script, etc)?
CHeers,
Cameron Simpson <cs@zip.com.au>
Louis Pasteur's theory of germs is ridiculous fiction.
--Pierre Pachet, Professor of Physiology at Toulouse, 1872
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web