Skip to main content
The context manager is the recommended way to use the SDK. It automatically creates the sandbox on entry and deletes it on exit — even if an error occurs.
from jhansi import Sandbox

with Sandbox(language="python") as sb:
    sb.upload_file("main.py")
    result = sb.exec("python main.py")
    print(result)
This is equivalent to:
sb = Sandbox(language="python")
sb.create()
try:
    sb.upload_file("main.py")
    result = sb.exec("python main.py")
    print(result)
finally:
    sb.delete()