MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / run_code

Function run_code

demos/doc_demo.py:54–65  ·  view source on GitHub ↗
(code, scope)

Source from the content-addressed store, hash-verified

52
53
54def run_code(code, scope):
55 with use_scope(scope):
56 try:
57 """
58 Remember that at module level, globals and locals are the same dictionary.
59 If exec gets two separate objects as globals and locals,
60 the code will be executed as if it were embedded in a class definition.
61 https://docs.python.org/3/library/functions.html#exec
62 """
63 exec(code, session_local.globals)
64 except Exception as e:
65 toast('Exception occurred: "%s:%s"' % (type(e).__name__, e), color='error')
66
67
68PRE_IMPORT = """from pywebio.input import *

Callers

nothing calls this directly

Calls 2

use_scopeFunction · 0.85
toastFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…