File processing

Bryan Olson fakeaddress at nowhere.org
Fri Sep 23 13:39:48 EDT 2005


Peter Hansen wrote:
 > Gopal wrote:
 >> [...] I'm
 >> thinking of going with this format by having "Param Name - value". Note
 >> that the value is a string/number; something like this:
 >>
 >> PROJECT_ID = "E4208506"
 >> SW_VERSION = "18d"
 >> HW_VERSION = "2"
 >>
 >> In my script, I need to parse this config file and extract the Values
 >> of the parameters.

 > Luckily, you're already done!  Just make sure the above file has a .py
 > extension, say maybe "config.py", and then in code where you need to
 > "parse" it and extract the values you can just do this:
 >
 > import config
 > print 'Project Id is', config.PROJECT_ID

In many cases that's fine, but at least be aware that the party
supplying the config data also gets the ability to change
the behavior of the process in ways of his choosing.


-- 
--Bryan



More information about the Python-list mailing list