diff --git a/esm/interpreter/pyodide.js b/esm/interpreter/pyodide.js index 1445aee..a0fa248 100644 --- a/esm/interpreter/pyodide.js +++ b/esm/interpreter/pyodide.js @@ -232,4 +232,16 @@ async function importPackages(packages, storage, save = false) { } micropip.destroy(); } +interpreter.runPython([ + 'import builtins, asyncio, inspect', + 'inputs = input', + 'def _input(prompt=""):', + ' """Asks for user input"""', + ' result = inputs(str(prompt))', + ' if inspect.isawaitable(result):', + ' return asyncio.run(result)', + ' else:', + ' return result', + 'builtins.input = _input' +].join(';'), { globals: interpreter.toPy({}) }); /* c8 ignore stop */