You can use the subprocess
module's piping features to write the data to the other program.
import subprocess
proc = subprocess.Popen("/usr/bin/tac", stdin=subprocess.PIPE) # Output will go to stdout
proc.communicate("hello\nworld\n") # This data goes to the subprocess.
will output (or rather, tac
will)
world
hello
EDIT: This is assuming the other program supports reading from standard input. If it doesn't, you could probably simulate this with fifos on UNIX-like systems...