mirror of https://github.com/pyodide/pyodide.git
Use JS multi-line string for Python code
so that the Python code looks nicer and is less error-prone to edit.
This commit is contained in:
parent
5a9f474717
commit
4e1ae73793
|
@ -24,16 +24,17 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
window.term = term;
|
window.term = term;
|
||||||
pyodide.runPython(
|
pyodide.runPython(`
|
||||||
'import io, code, sys\n' +
|
import io, code, sys
|
||||||
'from js import term, pyodide\n' +
|
from js import term, pyodide
|
||||||
'class Console(code.InteractiveConsole):\n' +
|
|
||||||
' def runcode(self, code):\n' +
|
class Console(code.InteractiveConsole):
|
||||||
' sys.stdout = io.StringIO()\n' +
|
def runcode(self, code):
|
||||||
' sys.stderr = io.StringIO()\n' +
|
sys.stdout = io.StringIO()
|
||||||
' term.runPython("\\n".join(self.buffer))\n' +
|
sys.stderr = io.StringIO()
|
||||||
'_c = Console(locals=globals())'
|
term.runPython("\\n".join(self.buffer))
|
||||||
)
|
_c = Console(locals=globals())
|
||||||
|
`)
|
||||||
|
|
||||||
var c = pyodide.pyimport('_c')
|
var c = pyodide.pyimport('_c')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue