Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
pyodide
Commits
4e1ae737
Commit
4e1ae737
authored
Mar 21, 2019
by
Marc Abramowitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use JS multi-line string for Python code
so that the Python code looks nicer and is less error-prone to edit.
parent
5a9f4747
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
src/console.html
src/console.html
+11
-10
No files found.
src/console.html
View file @
4e1ae737
...
...
@@ -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
'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment