Skip to main content
Use the code-interpreter template when you want a hosted notebook-like runtime with persistent kernel state, installed data libraries, rich results, and file artifacts.
from nullspace import Sandbox

with Sandbox.create(template="code-interpreter") as sandbox:
    result = sandbox.run_code("""
import pandas as pd

df = pd.DataFrame({"x": [1, 2, 3], "y": [1, 4, 9]})
df.describe()
""")
    print(result.results[0].text)
Code cells can share state through a context:
ctx = sandbox.code_interpreter.create_code_context(language="python", cwd="/workspace")
sandbox.code_interpreter.run_code("value = 21", context=ctx)
result = sandbox.code_interpreter.run_code("value * 2", context=ctx)
print(result.results[0].text)