[Python-Dev] ConfigParser to save with order (original) (raw)
Tony Meyer t-meyer at ihug.co.nz
Wed Jan 11 05:08:29 CET 2006
- Previous message: [Python-Dev] ConfigParser to save with order
- Next message: [Python-Dev] ConfigParser to save with order
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Guido]
I think it's moot unless you also preserve comments. Ideally would be something that prserved everything (ordering, blank lines, comments etc.) from how it was read in. Modifying a value should keep its position. Adding a value should add it to the end of the section it's in (unless there are cases where ordering is important to the semantics -- are there?).
[Facundo Batista]
We can rewrite ConfigParser to store everything and write it back in the exact order it took it, with new values at the end of each section (or where the user inserted it), but it'll took a big rewrite of the module: right now it's using dictionaries and should use lists to achieve that behaviour.
It's not at all that complicated. Simply running through the
original file when writing gets you the original order and comments.
This is simple to do (a simple example is in the SpamBayes source
code in the OptionsClass.py module).
Remember that there has been a lot of discussion about how
ConfigParser should work in the past; for example (ignoring c.l.p):
<http://mail.python.org/pipermail/python-dev/2004-October/049454.html> <http://mail.python.org/pipermail/python-dev/2004-October/049527.html> <http://aspn.activestate.com/ASPN/Mail/Message/python-dev/1483518>
=Tony.Meyer
- Previous message: [Python-Dev] ConfigParser to save with order
- Next message: [Python-Dev] ConfigParser to save with order
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]