I'm implementing a tool (java program) that embeds some command interpreters, as "bc", "sage", ... . The tool executes the interpreter in a thread, redirects its stdin and stdout, and writes some commands to the redirected stdin of the embedded interpreter (along time). Everything ok with "bc" and "sage" after solving usual problems with buffering.
In case of python, it seems that the interpreter is not reading its commands from stdin (I've verified that with a simple echo 1+2 | python
).
I do not find how to instruct the python interpreter to read its commands from stdin. I've read lots of similar questions, but all them tries to read data from stdin, not commands.
Note the command send to the python interpreter can be multi-line (a python "for" loop, ...) and commands are not yet available when python starts, they are generated and send to the interpreter along time.
In short, I want use python as a repl (read-eval-print-loop), reading from stdin.