[Tutor] The best way to implement a config file ???

Johan Geldenhuys johan at accesstel.co.za
Fri Feb 2 05:07:40 CET 2007


I've used two options in the past. The one is as Kent suggested, by using a
module that is imported by all others and share the values.
This doesn't allow for users to change the values, without changing the
code.

The second is to make use of a other file format. I used xml with all the
info in and extracted the values from there. It can be done with any type of
file, as long as you will know how to get the correct attributes for each
value.

HTH

Johan 

-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On Behalf
Of Kent Johnson
Sent: 01 February 2007 04:18 PM
To: Andreas Kostyrka
Cc: tutor at python.org
Subject: Re: [Tutor] The best way to implement a config file ???

Andreas Kostyrka wrote:
> * Magnus Wirström <asdlinux at yahoo.se> [070201 14:38]:
>> Hi everyone
>>
>> I'm learning to program python with wxpython gui. I have a 
>> application i made with several modules and i want to implement a 
>> configfile that applies to all those modules. Is there an easy way to 
>> do this ?  Can anyone point me in the right direction ?
> 
> Depending upon your tastes:
> 
> ConfigFile => win.ini style config files.
> shlex      => unix shell script style parsing.

You can also use a python module as a shared config; just define whatever
values you want in Python code and import the module where you need it.

Kent

_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.18/662 - Release Date: 2007/01/31
03:16 PM
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.18/662 - Release Date: 2007/01/31
03:16 PM
 



More information about the Tutor mailing list