Sujet : Re: Using 'with open(...) as ...' (Posting On Python-List Prohibited)
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.pythonDate : 30. Oct 2024, 02:10:14
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vfrth6$1p8n1$3@dont-email.me>
References : 1
User-Agent : Pan/0.160 (Toresk; )
On Tue, 29 Oct 2024 14:56:01 +0100, Loris Bennett wrote:
with open(args.config_file, 'r') as config_file:
I never bother with putting files into context managers. This is not a
good idea for files open for writing, but even for read-only files (as
here), CPython will close the file when the object goes out of scope
anyway.