create list for for-loop
<p>I have a script that creates a number of console links (with an html body built around) to VMs for faster access, the console links are put together by a number of strings and variables. </p>

<p>I want to create a list the contains all the links created. </p>

<p><strong>Nevermind I already created a list of all links, lost the overview of my script ...</strong></p>

<p>You may use <a href="https://docs.python.org/2/library/subprocess.html#subprocess.check_output" rel="nofollow"><code>subprocess.check_output()</code></a> which runs command with arguments and return its output as a byte string. For example:</p>

<pre><code>&gt;&gt;&gt; import subprocess
&gt;&gt;&gt; my_var = subprocess.check_output(["echo", "Hello"])
&gt;&gt;&gt; my_var
'Hello\n'
</code></pre>

<p>In case, you are having a executable file, say <code>my_script.py</code> which receives <code>param1</code> and <code>param2</code> as argument. Your <code>check_output</code> call should be like:</p>

<pre><code>my_output = subprocess.check_output(["./my_script.py", "param1", "param2"])
</code></pre>

<p>As per the document:</p>

<blockquote>
  <p><strong>Note:</strong> Do not use stderr=PIPE with this function as that can deadlock based on the child process error volume. Use Popen with the communicate() method when you need a stderr pipe.</p>
</blockquote>

python