How to parse this file using python?
<p>I have a file with contents like</p>

<pre><code>[Input:1]
Name=Feature1
Transform=Linear
Slope=1
Intercept=0

[Input:4]
Name=Feature2
Transform=Linear
Slope=1
Intercept=0

[Input:2]
Expression=( if ( &gt; Var 10000000) ( - Var 10000000) ( + Var 10000000))
Transform=Freeform

[Input:3]
Transform=FreeForm
Expression=(if (&gt; Var2 1) Var2 0)
Slope=1
Intercept=0
</code></pre>

<p>I need to create a list of objects with each object containing fields given above. Thus [Input:1] will correspond to object 1, there will be 4 variables inside given as Name, Transform, Slope and Intercept. The value ( in string) of that fields will be "Feature1", "Linear", "1" and "0" respectively. Note that each object can have different fields. How do I do this in python?</p>

<p>I guess u can try config</p>

<pre><code>import ConfigParser  
conf = ConfigParser.ConfigParser()  
conf.read("test.cfg")   
sections = conf.sections()  
print 'sections:', sections         #sections: ['sec_b', 'sec_a']  
options = conf.options("Input:1")  
</code></pre>

<p>but I misunderstand that how to define Expression, is it just a string</p>

python parsing text