This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Improve configparser.ConfigParser repr
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: lukasz.langa, remi.lapeyre, serhiy.storchaka
Priority: normal Keywords:

Created on 2019-02-18 13:13 by remi.lapeyre, last changed 2022-04-11 14:59 by admin.

Messages (3)
msg335831 - (view) Author: Rémi Lapeyre (remi.lapeyre) * Date: 2019-02-18 13:13
This is the current repr of the configparser.ConfigParser instances:

>>> import configparser
>>> config = configparser.ConfigParser()
>>> config['sec'] = {}
>>> config
<configparser.ConfigParser object at 0x10b656ad0>


I think this could be improved to read:

<ConfigParser sections=('sec',)>
msg335837 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-02-18 14:14
Why only sections? ConfigParser contains a lot of other information.

Section names you can get by calling the sections() method.

>>> config.sections()
['sec']
msg335839 - (view) Author: Rémi Lapeyre (remi.lapeyre) * Date: 2019-02-18 14:54
> Why only sections? ConfigParser contains a lot of other information.

Indeed, the defaults might be useful too. Other things like options
can be sessions specific and could clutter the repr if added.

Would defaults() and sections() be the right behavior between too
little information and too much?
History
Date User Action Args
2022-04-11 14:59:11adminsetgithub: 80204
2019-02-18 14:54:25remi.lapeyresetmessages: + msg335839
2019-02-18 14:14:25serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg335837
2019-02-18 13:47:06remi.lapeyresettitle: Import configparser.ConfigParser repr -> Improve configparser.ConfigParser repr
2019-02-18 13:42:51xtreaksetnosy: + lukasz.langa
2019-02-18 13:13:28remi.lapeyrecreate