ConfigParser - setting the order of options in a section

Mark McEahern mark at mceahern.com
Mon Jan 19 12:17:43 EST 2004


On Mon, 2004-01-19 at 09:24, S.Ramaswamy wrote:
> I am trying unsuccessfully to set the order of options [...]

Sections and options are internally stored by ConfigParser in
dictionaries.  I think the idea is that, as far as ConfigParser is
concerned, the order of sections and options within a section is
unimportant.  So if it *is* important to you, you're going to have to do
the ordering yourself.

Also, in your code, you seem to treat comments as if they were options,
setting them with set().  As far as I can tell, ConfigParser doesn't
provide anyway for you to associate a comment with an option.

What I'd do is provide your own write function or writer object that
does what you want it to do.

Cheers,

// m






More information about the Python-list mailing list