How to print output using python?
<p>When this .exe file runs it prints a screen full of information and I want to print a particular line out to the screen, here on line "6":</p>

<pre><code>    cmd =  ' -a ' + str(a) + ' -b ' + str(b) + str(Output)
    process = Popen(cmd, shell=True, stderr=STDOUT, stdout=PIPE)
    outputstring = process.communicate()[0]
    outputlist = outputstring.splitlines()
    Output = outputlist[5]
    print cmd
</code></pre>

<p>This works fine:
<code>cmd =  ' -a ' + str(a) + ' -b ' + str(b)</code> </p>

<p>This doesn't work:
<code>cmd =  ' -a ' + str(a) + ' -b ' + str(b) + str(Output)</code> </p>

<p>I get an error saying <code>Output</code> isn't defined.  But when I cut and paste:</p>

<pre><code>    outputstring = process.communicate()[0]
    outputlist = outputstring.splitlines()
    Output = outputlist[5]
</code></pre>

<p>before the cmd statement it tells me the process isn't defined.  <code>str(Output)</code> should be what is printed on line 6 when the .exe is ran.</p>
