From 4e1ae73793794d5007e470ac33b164950a0e55d2 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Thu, 21 Mar 2019 08:57:43 -0700 Subject: [PATCH] Use JS multi-line string for Python code so that the Python code looks nicer and is less error-prone to edit. --- src/console.html | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/console.html b/src/console.html index b8c0f0952..b5cecda7c 100644 --- a/src/console.html +++ b/src/console.html @@ -24,16 +24,17 @@ ); window.term = term; - pyodide.runPython( - 'import io, code, sys\n' + - 'from js import term, pyodide\n' + - 'class Console(code.InteractiveConsole):\n' + - ' def runcode(self, code):\n' + - ' sys.stdout = io.StringIO()\n' + - ' sys.stderr = io.StringIO()\n' + - ' term.runPython("\\n".join(self.buffer))\n' + - '_c = Console(locals=globals())' - ) + pyodide.runPython(` + import io, code, sys + from js import term, pyodide + + class Console(code.InteractiveConsole): + def runcode(self, code): + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() + term.runPython("\\n".join(self.buffer)) + _c = Console(locals=globals()) + `) var c = pyodide.pyimport('_c')