In a message of Tue, 01 Sep 2015 22:19:15 -, Grant Edwards writes:
>On 2015-09-01, Laura Creighton wrote:
>
>> Don't go around closing things you don't know are open. They
>> could be some other processes' thing.
>
>I don't understand. Closing a file descriptor that isn't open is
>harmless,
On 02Sep2015 08:01, Cameron Simpson wrote:
One circumstance where you might use fdopen and _not_ want .close to close the
underlying service is when you're handed a file descriptor over which you're
supposed to perform some I/O, and the I/O library functions use high level
files. In that case
On 2015-09-01, Laura Creighton wrote:
> Don't go around closing things you don't know are open. They
> could be some other processes' thing.
I don't understand. Closing a file descriptor that isn't open is
harmless, isn't it? Closing one that _is_ open only affects the
current process. If ot
On 01Sep2015 11:56, random...@fastmail.us wrote:
On Tue, Sep 1, 2015, at 10:57, Steven D'Aprano wrote:
Q3: I could probably answer Q2 myself if I knew how to check whether a
fd
was open or not. With a file object, I can inspect file_obj.closed and it
will tell me whether the file is open or no
In a message of Wed, 02 Sep 2015 00:57:22 +1000, "Steven D'Aprano" writes:
>Let's suppose somebody passes me a file descriptor to work with. It could
>come from somewhere else, but for the sake of discussion let's pretend I
>create it myself this way:
>Q1: In this example, I know that I opened th
On Tue, Sep 1, 2015, at 10:57, Steven D'Aprano wrote:
> Q1: In this example, I know that I opened the fd in write mode, because
> I
> did it myself. But since I'm not actually opening it, how do I know what
> mode to use in the call to fdopen? Is there something I can call to find
> out what mode
Let's suppose somebody passes me a file descriptor to work with. It could
come from somewhere else, but for the sake of discussion let's pretend I
create it myself this way:
import os
fd = os.open("some path", "w")
I then turn it into a file object:
file_obj = os.fdopen(fd, mode)
Q1: In this