import subprocess
cmd = 'python script.py'
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
out, err = p.communicate()
result = out.split('\n')
for lin in result:
if not lin.startswith('#'):
print(lin)
import_rand = False
if import_rand:
import random
print(int(random.randrange(10)))
elif not import_rand:
print(int(random.randrange(10)))