Generated by Spark: It doesnt pause to let me type: Welcome to the greeting program!

Hello, <coroutine object custom_input at 0xc4e9c8>! Nice to meet you!
Wow, <coroutine object custom_input at 0xc4f600> years old! That's awesome!
<coroutine object custom_input at 0xaf4cc0> is a great choice! I love that color too.
Thanks for chatting, <coroutine object custom_input at 0xc4e9c8>! Have a wonderful day!
This commit is contained in:
2026-01-17 19:56:14 +00:00
committed by GitHub
parent 9002991d85
commit 235e1b04a6

View File

@@ -140,14 +140,23 @@ sys.stderr = InteractiveStderr(__error_callback__)
await pyodide.runPythonAsync(`
import builtins
from pyodide.ffi import to_js
import asyncio
async def custom_input(prompt=""):
def custom_input(prompt=""):
import sys
sys.stdout.write(prompt)
sys.stdout.flush()
result = await js_input_handler(prompt)
return result
async def get_input():
result = await js_input_handler(prompt)
return result
loop = asyncio.get_event_loop()
if loop.is_running():
import pyodide.webloop
return pyodide.webloop.WebLoop().run_until_complete(get_input())
else:
return loop.run_until_complete(get_input())
builtins.input = custom_input
`)