Sending arguments to a program that is already open in Python 3
<p>What I am trying to do is better explained here: <a href="https://stackoverflow.com/questions/37560427/sending-to-the-stdin-of-a-program-in-python3">Sending to the stdin of a program in python3</a></p>

<p>I am trying to send arguments to a program while it is open e.g:</p>

<p>rec.py</p>

<pre><code>import sys
import time

while True:
   print(sys.argv)
   time.sleep(1)
</code></pre>

<p>send.py</p>

<pre><code>import subprocess

program = Popen(['python.exe', 'rec.py', 'testArg'])
a = input('input: ')
a.communicate(b)
</code></pre>

<p>I want to be able to run send.py and type in my input. Say my input was 'cat', I would want the output to look like this when I run send.py</p>

<pre><code>['rec.py', 'testArg']
['rec.py', 'testArg']
['rec.py', 'testArg']
cat &lt;------- My input
['rec.py', 'testArg', 'cat']
['rec.py', 'testArg', 'cat']
['rec.py', 'testArg', 'cat']
['rec.py', 'testArg', 'cat']
</code></pre>

<p>ect..</p>

<p>Am I using the subprocess.Popen.communicate() incorrectly or is it something else?</p>

<p>Please help!</p>

<p>-Thanks</p>