Clarify file-closing example in tutorial#11652
Conversation
I was helping a new Python user who was slightly confused by the tutorial's example of using the `with` keyword with file objects, because it seemed to them as though `f.closed` was something you needed to do in order to close the file. I think it's worth a brief clarifying sentence here to explain that `f.closed` is just here to demonstrate that the file object has been closed.
|
I thought this was probably trivial enough to not require either an issue or a NEWS entry, but I'm happy to add either or both of those if I'm mistaken about that. |
eamanu
left a comment
There was a problem hiding this comment.
LGTM. We have to wait the review of a core dev.
| After the :keyword:`with` statement, we can see that the file has been | ||
| automatically closed:: | ||
|
|
||
| >>> f.closed |
There was a problem hiding this comment.
This might be clearer as just an inline comment in order to keep the example all together in one block. So, before the f.closed(), how about:
>>> # We can check that the file has been automatically closed.
csabella
left a comment
There was a problem hiding this comment.
Please see inline comment.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Suggested by Cheryl Sabella.
|
I have made the requested changes; please review again. (Sorry for the delay.) |
|
Thanks for making the requested changes! @csabella: please review the changes made to this pull request. |
|
@cjwatson Thank you for the suggestion and the pull request! 🎉 |
I was helping a new Python user who was slightly confused by the
tutorial's example of using the
withkeyword with file objects,because it seemed to them as though
f.closedwas something you neededto do in order to close the file. I think it's worth a brief clarifying
sentence here to explain that
f.closedis just here to demonstratethat the file object has been closed.