File processing
Peter Hansen
peter at engcorp.com
Fri Sep 23 08:22:37 EDT 2005
Gopal wrote:
> Hello,
>
> I'm Gopal. I'm looking for a solution to the following problem:
>
> I need to create a text file config.txt having some parameters. 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.
>
> I'm very new to python as you can understand from the problem. However,
> I've some project dealines. So I need your help in arriving at a simple
> and ready-made solution.
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
-Peter
More information about the Python-list
mailing list