process.stdin.write('Hello\n')
print(repr(process.stdout.readline()))
process.stdin.write('World\n')
print(repr(process.stdout.readline()))
process.stdin.close()
print('Waiting for cat to exit')
process.wait()
print('cat finished with return code %d' % process.returncode)
Keep a subprocess alive and keep giving it commands? Python