mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-22 03:35:31 -05:00
[next] Testing XTerm (#1696)
This commit is contained in:
committed by
GitHub
parent
3aef5a99dc
commit
d8e1cb8b0f
22
pyscript.core/test/terminal.py
Normal file
22
pyscript.core/test/terminal.py
Normal file
@@ -0,0 +1,22 @@
|
||||
###### magic monkey patching ######
|
||||
import sys
|
||||
import builtins
|
||||
import js
|
||||
from pyscript import sync
|
||||
from pyodide.code import eval_code
|
||||
|
||||
sys.stdout = sync
|
||||
builtins.input = sync.readline
|
||||
|
||||
globals = {"js": js}
|
||||
|
||||
####### main code ######
|
||||
while True:
|
||||
code = input(f"> ")
|
||||
if len(code):
|
||||
try:
|
||||
result = eval_code(f"{code}", globals=globals)
|
||||
if result is not None:
|
||||
print(result)
|
||||
except:
|
||||
print(f"Unable to evaluate: {code}")
|
||||
Reference in New Issue
Block a user