Declaring variables in python
<p>I wanted parse a file to search one word and print next line i have written python script as follows</p>

<pre><code>infile = open("s.sdf","r")
output = open("sample.txt","w")
d = None
HD = None
HA = None
M = None

for line in infile:
      if line.startswith("&gt;  &lt;PUBCHEM_COMPOUND_CID&gt;"):
         d = infile.next().strip()
         print d      
      elif line.startswith("&gt;  &lt;PUBCHEM_CACTVS_HBOND_DONOR&gt;"):
         HD = infile.next().strip()
         print HD
      elif line.startswith("&gt;  &lt;PUBCHEM_CACTVS_HBOND_ACCEPTOR&gt;"):
         HA = infile.next().strip()
         print HA
      elif line.startswith("&gt;  &lt;PUBCHEM_MOLECULAR_WEIGHT&gt;"):
         M = infile.next().strip()
         print M

      print "%s \t  %s  \t  %s  \t  %s" %(d,HD,HA,M)
      output.write("%s  \t  %s  \%s \t  %s" %(d,HD,HA,M))
</code></pre>

<p>But unfortunately i getting an error as follows</p>

<pre><code>None None None None

None None None None

None None None None

None None None None
.......
</code></pre>

<p>Can anybody tell me how to solve this..</p>

<p>Thanks in Advance</p>

<p>N</p>
