main.py
import subprocess,sys
process = subprocess.Popen([sys.executable]+['example.py'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while True:
out = process.stdout.read(1)
if not out:
out=process.stderr.read(1)
if out == '' and process.poll() != None:
break
if out != '':
print out
example.py
f=raw_input('WHats your favorite animal')
Ok I am wondering how I can check for input in my main loop and be able to give some data to it. Right now my program freezes when I use raw_input.
Here is what I would like
while True:
out = process.stdout.read(1)
if not out:
out=process.stderr.read(1)
if out == '' and process.poll() != None:
break
#showing what i want
if request_input==True:
give_input('cat') #Give input to the raw_input
#
if out != '':
print out
I dont know if there is a feature like this. If you need more explanation please comment.