[Python-Dev] ConfigParser shootout, preliminary entry
carribeiro at gmail.com
Mon Oct 18 21:51:58 CEST 2004
On Mon, 18 Oct 2004 12:20:46 -0700, Josiah Carlson <jcarlson at uci.edu> wrote:
> > > I think the syntax looks good, but as per a thread in python-list, you
> > > cannot discover the order of class variables by any solution (metaclass
> > > or otherwise), due to the fact that they become part of the class
> > > dictionary; which is arbitrarily unordered.
> > >
> > > If ordering is important to a user, one could have an optional
> > > __order__
> > > attribute that gives the list of items in-order.
> > That's not quite true. TypedAttribute instances and iniSection's
> > __new__ could have serial numbers.
TypedAttributes store their own sequence numbers using a simple
counter. Bengt Richter also came up with a clever trick to retrieve a
list from the code object itself (using the inspect module and the
co_names member). It's very powerful, but it can't check all
situations, but I'm sure that it would work for most real world
As far as INI files are concerned, order is good but not essential. It
helps people that are going to read, or manually edit the config file,
and avoids some surprised such as in "what has happened here?" when
things seems to appear "out of order".
> I'm not saying that they can't be numbered, I'm saying that one cannot
> discover the ordering of assignment of attr1 and attr2 in the following:
> class foo:
> attr1 = value1
> attr2 = value2
> If there is a mechanism for discovering the original ordering of those
> assignments, there are a group of users in c.l.py who would like to know,
> and Carlos' seemingly non-existant implementation could also use it.
I took part in that discussion. We found some a few alternatives to
handle this problem. None of them are 100% percent transparent _and_
reliable; you had to choose here between the two options. But for
things such as ini files, things don't look that bad.
As for the code: I don't have a host for it, and I just felt that I
shouldn't post it in the python-dev list without some proper care :-)
But I'm going to do it as soon as I have a 'good enough'
implementation that include the write code. BTW I'll move this
discussion to the main python list. If anyone cares enough about it,
I'll move it back into python-dev.
> Please advise,
> - Josiah
Consultoria em Projetos
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com
More information about the Python-list