import subprocess
# Create a Popen class instance and run command `cat` in a seperate process
proc = subprocess.Popen(
['cat', '-'],
# Also we're going to send come data into command's standard input, so
# we indicate that it would be PIPE
stdin=subprocess.PIPE,
# And we shall read output as a stream
stdout=subprocess.PIPE
)
# Let us start communication
stdout_value = proc.communicate('string to read')
print stdout_value