title: Variables that have been assigned in a line.split() command, are not read into a function
body: <p>In this code the variables <code>pressure</code> and <code>enthalpy</code>, that come from a <code>[float(n) for n in line.split()]</code> command, are not read into a function:</p>
  
  <pre><code>import numpy as np
  
  pressure_gibbs = open('pressure_gibbs_all_points.dat', 'w')
  
  pressure_gibbs.write('#pressure    gibbs\n')
  
  ## FUNCTIONS:
  
  def G(H,S):
  # G = H - TS 
  # Then:
    gibbs = H - 298.15 * S/4.0
    return gibbs
  
  
  
  with open('entropies_parsed.dat') as entropies_parsed, open('pressure_enthalpy_all_points.dat') as enthalpy_pressure:  # open the file
    entropies_parsed.next() # skip the first line
    enthalpy_pressure.next()
  
    entropy = [float(line) for line in entropies_parsed]
    #print entropy
    for line in enthalpy_pressure:
         #print entropy
          pressure, enthalpy = [float(n) for n in line.split()]
          #print pressure
          #print enthalpy
          for i in entropy:
              #print i
              gibbs = G(enthalpy, i)
              #print gibbs
              pressure_gibbs.write('{}\t{}\n'.format (pressure, gibbs))
  
  pressure_gibbs.close()
  </code></pre>
  
  <p>Only two files in this folder are necessary to run this code:</p>
  
  <p><code>pressure_enthalpy_all_points.dat</code>: </p>
  
  <pre><code># pressure enthalpy
  2         3
  5         4
  3.5       2
  </code></pre>
  
  <p><code>entropies_parsed.dat</code>: </p>
  
  <pre><code># entropies
  0.5        
  0.2        
  0.47       
  </code></pre>
  
  <p>This is the best I could achieve, and the indentation position is right, from my knowledge. </p>
  
  <p>However, 
  <strong>this code gives a file</strong>, <code>pressure_gibbs_all_points.dat</code>:</p>
  
  <pre><code>#pressure    gibbs
  2.0     -34.26875
  2.0     -11.9075
  2.0     -32.032625
  5.0     -33.26875
  5.0     -10.9075
  5.0     -31.032625
  3.5     -35.26875
  3.5     -12.9075
  3.5     -33.032625
  </code></pre>
  
  <p>which is wrong. </p>
  
  <p>I would appreciate if you could help me please.</p>