[Tutor] setting program configuration for all files and modules ofa program

Alan Gauld alan.gauld at btinternet.com
Tue Apr 15 22:21:58 CEST 2008


"Tim Michelsen" <timmichelsen at gmx-topmail.de> wrote

>> import myconfig
>> foo2 = myconfig.SectionFoo['second']
> This seems like reinventing what the ConfigParser 
> mdoule [1] already does.

But with the advantage that its pure python, no parsing 
needed so its both faster and avouds any string to int 
type conversions

> But to my optinion Config Parser offers the following advantage:
> - Readable
> - All are strings => no strange 'mysetting' is needed.

I'm not sure what you mean. The Python variables and dictionary 
is all strings too. mysetting is just a string...

But the choice is yours, you can use config parser to parse 
a config file into variables in a settings module or you can 
create the settings directly in the settings module.

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list