close() the file when opening "with"?
Terry Reedy
tjreedy at udel.edu
Sun Jun 14 09:06:32 EDT 2020
On 6/14/2020 6:36 AM, Bischoop wrote:
> On 2020-06-14, Chris Angelico <rosuav at gmail.com> wrote:
>> On Sun, Jun 14, 2020 at 8:16 PM Bischoop <Bischoop at vimuster.net> wrote:
>>>
>>>
>>> So far I learnt "with" closes the file opened therefore "Generally" no
>>> need to close() file. I'm worry about this "Generally", then close() or
>>> not?
>>
>> Where did you learn that? Can you cite a reference?
>>
>> If you use a with block, the file is guaranteed to be closed as you
>> exit that block. It's that simple.
>>
>> ChrisA
>
> Where I learnt what that "with" closes the file or that "Generally" no
> need to close() file when using "with"?
The latter. Chris said that the former is true. The qualification in
the latter should not be.
--
Terry Jan Reedy
More information about the Python-list
mailing list