How to run processes in the background and override standard streams
Question: I want to write a python script which should create a process **in the
background** , redirect its **stdin** , **stdout** and **stderr** for
communication with that process (this executable is my program) to a
**separate** virtual streams.

I need to run several instances of my program at once from python script and i
need a proper solution to receive/send messages to their overriden streams. I
have no experience on sub/process/streams in python, i am looking for a
diamong code sample, thank you..


Answer: What you're after is
[subprocess.Popen](https://docs.python.org/2/library/subprocess.html#subprocess.Popen):

    
    
    import subprocess
    p = subprocess.Popen(["mycmd", "--somearg"], stdout=subprocess.PIPE)
    out, err = p.communicate()
    

