Closed brianpmarks closed 9 years ago
You can use the .write method to send a string to the process' stdin. Unfortunately, I found it really hard and unreliable to try to detect when a process is waiting for input across all languages I support.
One workaround could be that you monkey patch the input function in Python so you can insert your custom logic there.
Thanks. I've got a rough implementation working now. Probably good enough for most situations.
Curious, did you monkey patch python input on the repl.it site? https://repl.it/BISI/2
I'm trying out the python3 api over at trinket.io and can't find a good way to handle stdin from users. Is there a stdin option, similar to stdout, that could be passed to evaluate? Any other way to identify when a program is waiting for user input?
A trivial example in python might be: