import subprocess 

proc = subprocess.Popen(
    ['cat', '-'],
    stdin=subprocess.PIPE,
)

proc.communicate('stdin: to stdin\n'.encode('utf-8'))
import subprocess 

proc = subprocess.Popen(
    ['cat', '-'],
    stdin=subprocess.PIPE,
)

proc.communicate('stdin: to stdin\n'.encode('utf-8'))