mirror of
https://github.com/johndoe6345789/snippet-pastebin.git
synced 2026-04-24 13:34:55 +00:00
Generated by Spark: It's supposed to accept interactive real time input, instead I get Traceback (most recent call last):
File "/lib/python313.zip/_pyodide/_base.py", line 523, in eval_code
.run(globals, locals)
~~~^^^^^^^^^^^^^^^^^
File "/lib/python313.zip/_pyodide/_base.py", line 357, in run
coroutine = eval(self.code, globals, locals)
File "<exec>", line 3, in <module>
ImportError: cannot import name '__js_input__' from 'js' (unknown location)
This commit is contained in:
@@ -139,16 +139,18 @@ sys.stderr = InteractiveStderr(__error_callback__)
|
||||
|
||||
pyodide.runPython(`
|
||||
import builtins
|
||||
from js import __js_input__
|
||||
import asyncio
|
||||
|
||||
async def custom_input_async(prompt=""):
|
||||
sys.stdout.write(prompt)
|
||||
sys.stdout.flush()
|
||||
|
||||
from js import __js_input__
|
||||
result = await __js_input__(prompt)
|
||||
return result
|
||||
|
||||
def custom_input(prompt=""):
|
||||
import asyncio
|
||||
loop = asyncio.get_event_loop()
|
||||
result = loop.run_until_complete(custom_input_async(prompt))
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user