On Jun 27, 3:18 pm, kj <no.em...@please.post> wrote: > In <c91011ad-b52c-4fb7-8e2c-1de165636...@d32g2000yqh.googlegroups.com> Aaron > Sherman <aaronjsher...@gmail.com> writes: > > >On Jun 27, 4:38=A0pm, MRAB <pyt...@mrabarnett.plus.com> wrote: > >> > I would appreciate your comments and suggestions. > > >> There are already modules which provide access to databases. > >As you can see the "Python Way" is to be rude ;-) > >Anyway, your answer is that there are some abstraction layers called > >"ORMs". You can grab one of these and write a back end for it. > >However, you might first want to look at SQLLite and see if it already > >has what you want (e.g. a light-weight, zero-install database > >interface). > > Hi, thanks, but the database aspect of my question is tangential. > What I'm interested in is the general problem of providing > configuration parameters to a module.
The best way to do this totally depends on how complex these parameters are. Are they simple one-to-one key-value pairs? Then the frontend should explose a dict interface. There are probably existing third-party libraries that expose dict-like interfaces to all of your imagined backends. Check pypi.python.org, and also Python cookbook. If the configuration is more complex, such as if it is hierarchical, if it includes many-to-many relationships, if it is graph-like, then a more sophisticated frontend will be needed. For these situations I second the recommendation to consider an ORM (such as SqlAlchemy). I am not aware of any ORMs that can use SQL, XML, and tab-delimited text all as backends, though. I am not a big database guy though. Also, I exhort to you consider whether you really need so many different backends for a configuration file. Might your time be better spent improving some other aspect of your application? Carl Banks -- http://mail.python.org/mailman/listinfo/python-list