Guido van Rossum wrote: > What I have come to like, both for dealing with XML and with .ini > files, is something that lets you map the configuration values (or > whatever it is that you're parsing, really) to Python attributes. This > is really some kind of simplified DTD support, and there are different > ways to go about it; but the net result is that you end up writing > e.g. options.client.max_retries (which is an int with a default value) > rather than options.getint("client", "max-retries"). That's exactly what I wrote for ipython's option handler, with a fairly complex (and brittle) code to allow recursive loading of config files, since ipython has the (very useful, it turns out) concept of configuration 'profiles' which can include generic defaults and override them for specialized tasks. This means that options files can specify include statements to pull in other files, recursively. This has proven to be very useful, the rc format is a plain text key/value pair, and internally the options structure is (almost) a simple class with attributes for the options. Because I wrote this in my second week of learning python, the actual implementation is an atrocious mess, and the options class unfortunately has its own methods, which prevents having options with certain reserved names (basically all the methods of a dict). This last part was obviously a big mistake. But the overall idea, despite the shortcomings of my implementation, I think satisfies multiple important (for me) requirements: - flat text for users to edit without pulling them into the mudpit of XML. I simply refuse to ask a user to hand-edit XML, period. From an aesthetic standpoint, I think it would be borderline criminal to do so. - recursive inclusion for handling complex configuration situations. - exposes the options as a simple object with attributes accessible as rc.opt1, rc.opt2, etc. This makes the code which uses all these options (IPython has a _ton_ of cmd line flags) as readable as possible. Anyway, this is just $.02 from yet another one who reinvented this particular wheel... Best, f. ps. On the topic of @decorators and IPython, after some consultations with the ipython user community, the next release will use % for magic functions. This should be out in a few weeks, far before 2.4 is officially out.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4