Running python from pty without prompt

space.ship.traveller at gmail.com space.ship.traveller at gmail.com
Fri Dec 9 18:11:32 EST 2016


Hello.

I'm working on a script runner for Atom.

https://github.com/ioquatix/script-runner

We are trying to understand how to make python work well. I'll use a comparison to the ruby executable because it's convenient to explain the problem.

When you invoke `ruby` from a pty, you get no output (as opposed to `irb`, interactive ruby [shell]). You can write a script to stdin, and send Ctrl-D (EOT / 0x04). Then, ruby will execute the script. stdin is not closed so programs that expect interactive input will work correctly.

When we run python in the same way, we get an output prompt. As soon as a function like `input` is called, the program is interrupted.

I'm happy to hear feedback about how this should work. Perhaps our expectations are wrong, or what we are doing is wrong.

One option which we've been considering is saving the input as a file and executing that. But, it's not as clean compared to simply writing a string to stdin of a running interpreter and then 0x04.

Thanks for any and all help.

Kind regards,
Samuel


More information about the Python-list mailing list