How to ping from a tuple?
<p>How can I ping a list of hosts from a tuple and store the response into another tuple, list?</p>

<p>I know how to ping a single host:</p>

<pre><code>hostname = "10.0.0.250" #example

response = os.system("ping -c 1 " + hostname)
</code></pre>

<p>You can simply use a <em>list comprehension</em> / <em>generator expression</em> (for tuple), given a tuple of hostnames:</p>

<pre><code>hostnames = ("10.0.0.250", "10.0.0.240", ...)
responses = tuple(os.system("ping -c 1 " + h) for h in hostnames)
</code></pre>

python