Subprocess with a Python Session?

Calvin Spealman ironfroggy at gmail.com
Tue Dec 5 14:44:17 EST 2006


On 12/5/06, Fredrik Lundh <fredrik at pythonware.com> wrote:
> Calvin Spealman wrote:
>
> > No matter what I do I cant get the following code to do what I expect.
> > I hadn't used subprocess t o read and write to pipes of a
> > still-running app, and I just can't seem to get it right. What gives?
> >
> > import subprocess
> >
> > p = subprocess.Popen("python", stdout=subprocess.PIPE, stdin=subprocess.PIPE)
> > p.stdin.write('print 10\n')
>
> + p.stdin.close()
>
> > assert p.stdout.readline() == '10\n'
>
> </F>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

I know I can do that, but I am specifically trying to not close the
pipe or terminate the process. I need to write additional statements,
read additional output, etc.

-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://ironfroggy-code.blogspot.com/



More information about the Python-list mailing list