Running a program from another program.


Laurent Verweijen

I have a program called as follows:

n = 0
while True:
n = int(raw_input(n)) + 1

This is probably very easy to understand, but I want to run this program
from another python program.
Below is an attempt
>>> from subprocess import *
>>> p = Popen(["python", ""], stdin=PIPE, stdout=PIPE)
>>> p.communicate("5")
Traceback (most recent call last):
File "", line 4, in <module>
n = int(raw_input(n)) + 1
EOFError: EOF when reading a line
('06', None) Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/", line 701, in
return self._communicate(input)
File "/usr/lib/python2.6/", line 1184, in
ValueError: I/O operation on closed file

How do I make sure the inputstream stays open after the first call to


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question