In conventional (non-browser based) Python, it is common to run scripts from
the terminal, or to interact directly with the Python interpreter via the
It's to the terminal that
stdout), and it's
from the terminal that the
input reads characters (via
It usually looks something like this:
Because of the historic importance of the use of a terminal, PyScript makes one
available in the browser (based upon XTerm.js).
As mentioned earlier, PyScript's built-in terminal is activated
terminal flag when using the
MicroPython currently doesn't work with the terminal.
Terminal support for MicroPython is coming, just as soon as a new version of MicroPython is released.
This is, perhaps, the simplest use case that allows data to be emitted to a read-only terminal:
The end result will look like this (the rectangular box indicates the current position of the cursor):
Should you need an interactive terminal, for example because you use the
input statement that requires the user to type things into the terminal, you
must ensure your code is run on a worker:
To use the interactive Python REPL in the terminal, use Python's code module like this:
The end result should look something like this: