Best use of "open" context manager

Cameron Simpson cs at cskk.id.au
Sun Jul 7 22:45:21 EDT 2024


On 07Jul2024 22:22, Rob Cliffe <rob.cliffe at btinternet.com> wrote:
>it's legal, but doesn't work (trying to access the file after "with f" 
>raises the same
>    ValueError: I/O operation on closed file.

Just to this: of course. The with closes the file. But my version runs 
the with after the try/except.


More information about the Python-list mailing list