I can create a REPL and see the output using
<py-repl
id={`my-repl`}
auto-generate='false'
std-out={`output`}
std-err={`err-div`}>
</py-repl>
<div id={`output`} class="replOutput"></div>
As I understand, when I press "start", py-script
executes some code under the hood to run the code in the REPL and create new <div>
elements for each new line of output.
Currently, it is creating new output divs, every time you run the REPL. I want only the most recent outputs to be shown. I tried using CSS to select just the final element (using :nth-last-child()
) but if I have multiple print statements, only the last print output is shown.
Looking at the source code. It seems that you can set py-repl
attribute output-mode
to replace
(default seems to be append
):
<py-repl
id={`my-repl`}
auto-generate='false'
output-mode='replace'
std-out={`output`}
std-err={`err-div`}>
</py-repl>