aboutsummaryrefslogtreecommitdiffstats
path: root/tools/execute_py_code.py
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-10-26 08:32:36 +0800
committersigoden <sigoden@gmail.com>2024-10-26 08:32:36 +0800
commit602ca0535e8d79e1e9362f870e3583e5bbedfe5b (patch)
tree0cec1846f5fffbc43501db2f47de60c5518d27b7 /tools/execute_py_code.py
parente1a26cb4f2032dfb44908ecb73b9039ca1c7dc04 (diff)
downloadllm-functions-docker-602ca0535e8d79e1e9362f870e3583e5bbedfe5b.tar.gz
chore: execute js/py code
Diffstat (limited to 'tools/execute_py_code.py')
-rw-r--r--tools/execute_py_code.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/execute_py_code.py b/tools/execute_py_code.py
index ad9310c..a8cfe48 100644
--- a/tools/execute_py_code.py
+++ b/tools/execute_py_code.py
@@ -7,10 +7,10 @@ def run(code: str):
code: Python code to execute, such as `print("hello world")`
"""
old_stdout = sys.stdout
- new_stdout = io.StringIO()
- sys.stdout = new_stdout
+ output = io.StringIO()
+ sys.stdout = output
exec(code)
sys.stdout = old_stdout
- return new_stdout.getvalue() \ No newline at end of file
+ return output.getvalue() \ No newline at end of file