title: Extracting variables from set of strings in python
body: <p>I have a set of strings that I extracted and stored into an array. Some of these contain variables that I want to extract, the problem is these are strings at the moment. So for example, one string would look like </p>
  
  <pre><code>s1 = 'DataFile=scan1.dat'
  </code></pre>
  
  <p>Others would look like</p>
  
  <pre><code>s2 = 'NumberOfChannels=32'
  </code></pre>
  
  <p>What I want to do is take s1 and s2 and extract from them info and store them as such:</p>
  
  <pre><code>DataFile='scan1.dat'
  NumberOfChannels=32
  </code></pre>
  
  <p>The strings all look similar to the ones above. It's either a variable that contains a string itself, or a variable containing an integer. Here's my (failed) attempt at the integer case: </p>
  
  <pre><code>            # ll is a string element of the big array
  
              if ll.startswith('NumberOfChannels'): 
                  print "found nChans"
                  idx = ll.index('=')
                  vars()[ll[:idx-1]] = int(ll[idx+1:])
  </code></pre>
  
  <p>Any suggestions/external modules that could help me out would be greatly appreciated</p>