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: configparser instances cannot be pretty printed
Type: enhancement Stage:
Components: Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Andrei.Kucharavy, iritkatriel, lukasz.langa, r.david.murray
Priority: normal Keywords:

Created on 2013-12-16 00:13 by Andrei.Kucharavy, last changed 2022-04-11 14:57 by admin.

Messages (3)
msg206267 - (view) Author: Andrei Kucharavy (Andrei.Kucharavy) Date: 2013-12-16 00:13
ConfigParser seems to share a lot of behavior with a dict, but cannot be pretty printed.
msg206270 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-12-16 01:06
Without looking at the details, I would guess that doing anything about this should have issue 7434 as a prereq.  But  Łukasz will have a more informed opinion.
msg415566 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-03-19 20:06
It's not just that it can't be pretty printed - it doesn't even have __str__ or __repr__.

I think the only thing we have now it write, which can do this:

>>> config = configparser.ConfigParser()
>>> config['DEFAULT'] = {'ServerAliveInterval': '45','Compression': 'yes','CompressionLevel': '9'}
>>> f = io.StringIO()
>>> config.write(f)
>>> f.getvalue()
'[DEFAULT]\nserveraliveinterval = 45\ncompression = yes\ncompressionlevel = 9\n\n'
>>> pprint.pprint(f.getvalue())
('[DEFAULT]\n'
 'serveraliveinterval = 45\n'
 'compression = yes\n'
 'compressionlevel = 9\n'
 '\n')
>>>


Is this enough, or should something be added?
History
Date User Action Args
2022-04-11 14:57:55adminsetgithub: 64190
2022-03-19 20:06:01iritkatrielsetnosy: + iritkatriel
messages: + msg415566
2013-12-16 01:06:32r.david.murraysetnosy: + r.david.murray, lukasz.langa

messages: + msg206270
versions: + Python 3.5, - Python 3.3
2013-12-16 00:13:55Andrei.Kucharavycreate