Re: Using 'with open(...) as ...' together with configparser.ConfigParser.read

Liste des GroupesRevenir à cl python 
Sujet : Re: Using 'with open(...) as ...' together with configparser.ConfigParser.read
De : jon+usenet (at) *nospam* unequivocal.eu (Jon Ribbens)
Groupes : comp.lang.python
Date : 30. Oct 2024, 17:41:13
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <slrnvi4ksp.372.jon+usenet@raven.unequivocal.eu>
References : 1 2 3
User-Agent : slrn/1.0.3 (Linux)
On 2024-10-30, Loris Bennett <loris.bennett@fu-berlin.de> wrote:
Jon Ribbens <jon+usenet@unequivocal.eu> writes:
As per the docs you link to, the read() method only takes filename(s)
as arguments, if you have an already-open file you want to read then
you should use the read_file() method instead.
>
As you and others have pointed out, this is indeed covered in the docs,
so mea culpa.
>
However, whereas I can see why you might want to read the config from a
dict or a string, what would be a use case in which I would want to
read from an open file rather than just reading from a file(name)?

The ConfigParser module provides read(), read_file(), read_string(),
and read_dict() methods. I think they were just trying to be
comprehensive. It's a bit non-Pythonic really.

Date Sujet#  Auteur
29 Oct 24 * Using 'with open(...) as ...' together with configparser.ConfigParser.read12Loris Bennett
29 Oct 24 +* Re: Using 'with open(...) as ...' together with configparser.ConfigParser.read9Jon Ribbens
30 Oct 24 i`* Re: Using 'with open(...) as ...' together with configparser.ConfigParser.read8Loris Bennett
30 Oct 24 i `* Re: Using 'with open(...) as ...' together with configparser.ConfigParser.read7Jon Ribbens
30 Oct 24 i  `* Re: Using 'with open(...) as ...' together with configparser.ConfigParser.read6Loris Bennett
30 Oct 24 i   `* Re: Using 'with open(...) as ...' together with configparser.ConfigParser.read5Jon Ribbens
31 Oct 24 i    `* Re: Using 'with open(...) as ...' together with configparser.ConfigParser.read4Loris Bennett
31 Oct 24 i     +- Re: Using 'with open(...) as ...' together with configparser.ConfigParser.read1Jon Ribbens
31 Oct 24 i     +- Re: Using 'with open(...) as ...' together with configparser.ConfigParser.read1Karsten Hilbert
31 Oct 24 i     `- Re: Using 'with open(...) as ...' together with configparser.ConfigParser.read1MRAB
29 Oct 24 +- Re: Using 'with open(...) as ...' together with configparser.ConfigParser.read1MRAB
30 Oct 24 `- Re: Using 'with open(...) as ...' (Posting On Python-List Prohibited)1Lawrence D'Oliveiro

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal