dont use javascript prompt() for python input()
🐛 Bug
python input() is implemented with javascript prompt()
To Reproduce
input()
import sys; sys.stdin.read(1)
Expected behavior
no javascript prompt() popup
the input should be read by the terminal emulator (or from the stdin stream)
this is needed to create simple user input prompt apps
the user input should happen in the context of the terminal buffer not in a popup window that hides the terminal buffer
Environment
- Pyodide Version: 0.28.0 at https://pyodide.org/en/stable/console.html
- Browser version:137.0.7151.119
- Any other relevant information:
Additional context
related: #2887 #1219
alternative: https://github.com/sagemathinc/cowasm
You can use pyodide.setStdin() to configure this how you like. I'm not sure I'd consider it a bug, the alternative option would be to always raise an error or always return an empty string.
docs: pyodide.setStdin
but this is not implemented in pyodide
see also cowasm/docs/differences-from-pyodide.md#synchronous-input
What is not implemented in Pyodide?
https://cowasm.org/
>>> input()
asdf
'asdf'
... without a javascript prompt popup
You can call pyodide.setStdin() and configure this in Pyodide to work how you like.
how exactly? docs dont help
Cowasm runs on WebWorker, if you want to make input work without blocking the main thread, you should do the same thing.
This video will help you understand what kind of things are required: https://youtu.be/-SggWFS15Do?si=SqfbhnpwHnmMn0Q1