larzsandbox
Run learner code safely-ish.
Run code a beginner wrote and survive their honest mistakes: restricted builtins (no open/exec/eval/import), captured output, and a timeout, returning a tidy result instead of crashing. For education and autograding - honest that it's not a hardened security boundary.
larzscript pkg install sandbox
What you get
- Restricted builtins, imports off
- Timeout stops infinite loops
- Captures output + errors
- check_output() for autograding
Try it
import "sandbox" as sandbox
let box = sandbox.new({"timeout": 3})
let result = sandbox.run(box, "print(1 + 2)")
print(result["output"].strip(), result["ok"])
let denied = sandbox.run(box, "import \"os\" as os")
print(denied["ok"], denied["violations"])Output
3 true false [imports are not allowed]
Why it's in the Larz Stack
larzsandbox is a real Larzscript package (larzscript pkg install sandbox) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.