On 08/02/2018 12:43 PM, Paul Moore wrote:
I'm not sure I see why you think it wouldn't - opening and closing the
file is a purely internal detail of the function. In any case, you
don't get given a file object, so how could anything *other* than the
read_text() close the file? So you're basically asking "does
Path.read_text() have a bug that causes it to leak a filehandle?" to
which my answer would be "I assume not, until someone demonstrates
such a bug".
To me the following look the same:
Path('file').read_text()
open('file').read()
The first presumably creates a Path object while the second creates a
file object. Why should I assume that the Path object closes the
underlying file object after the method is called? I mean maybe my
assumption is bad, but I doubt I'd be the only one making it given how
open() works and that it looks similar superficially.
Cheers,
Thomas
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/