what does "python -i" use as input stream (stdin)?

Almar Klein almar.klein at gmail.com
Fri Sep 26 03:29:42 EDT 2008


>
> Use subprocess.PIPE
> Usually the tricky part is to figure out exactly whether there is more
> input or not. With Python it's easy, use the ps1 prompt.


Thanks, but that is not exactly what I meant. (Maybe my question was
a bit vague). I want to replace the input stream of the *remote* process.
So I'll be running something like "python -i remote.py", and inside
remote.py
I create a pseudo-file to replace the input stream (of the remote process).

I have now solved my problem by running "python remote.py" (without the -i)
and start an interactive interpreter (inherited from
code.InteractiveConsole).
This interpreter *does* use the sys.stdin, so I can just do:
"sys.stdin = my_pseudo_file"

(I start a separate thread that reads the original stdin and writes received
text to
the pseudofile. But now I can also communicate and do stuff with the process
when the main thread is running (for example interrupting it on windows!))

I would still like to hear if anyone knows how I can change the input stream
that
is used when running "python -i", but I would not be surprised if it is
impossible...

Almar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080926/388715e6/attachment-0001.html>


More information about the Python-list mailing list