Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #196378

Re: Best use of "open" context manager

From 2QdxY4RzWzUUiLuE@potatochowder.com
Newsgroups comp.lang.python
Subject Re: Best use of "open" context manager
Date 2024-07-06 07:09 -0400
Message-ID <mailman.4.1720265784.2981.python-list@python.org> (permalink)
References <954c4ca8-cf37-4482-a1be-46d39cb503f9@btinternet.com> <Zokl-STBBSgf3xJE@anomaly>

Show all headers | View raw


On 2024-07-06 at 11:49:06 +0100,
Rob Cliffe via Python-list <python-list@python.org> wrote:

> Is there a better / more Pythonic solution?

https://docs.python.org/3/library/fileinput.html

At least this attempts to abstract the problem of iterating over a file
(or multiple files) into a library routine.  I've used it a little, but
I don't know the full depths of your use case and/or requirements.

HTH,
Dan

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Best use of "open" context manager 2QdxY4RzWzUUiLuE@potatochowder.com - 2024-07-06 07:09 -0400

csiph-web