Correction Helper
Project
This is just a set of tools to help writing correction bots in Python for Python.
It is used for hackinscience, but could be used elsewhere.
Security considerations
Running student code is probably really unsafe, unless you trust your students not to drop you a backdoor.
This projet does not help with security in any ways, maybe take a
look at firejail if you have
trust issues (Yes you can use correction-helper inside firejail).
Usage
To install it, run: pip install correction-helper.
In your checking code, you can use it like this:
The student_code decorator
This decorator is aimed to catch most problems that could happen in student code, use it simply as:
with student_code():
their_function()
Find a more complete example in the examples/ directory.
Allowed parameters for student_code, and their default values
print_prefix="Your code printed:"
Message to display before the student prints (in case print_allowed
is False or None).
It's allowed to give a list of strings, in which case they'll be
separated by "\n\n", useful to render markdown paragraphs.
too_slow_message="Your program looks too slow, looks like an infinite loop."
Message to display in case the code runs slower than the given timeout (defaults to 1s).
It's allowed to give a list of strings, in which case they'll be
separated by "\n\n", useful to render markdown paragraphs.
prefix=()
A prefix for print_prefix, exception_prefix, and
too_slow_message=, usefull to deduplicate strings, like:
with student_code(
prefix="While calling blahblah('bar')",
print_prefix="it printed:",
exception_prefix="it raised:",
too_slow_message="it took more than 1s, had to kill it.",
):
blahblah('bar')
friendly=False
To use, or not friendly-traceback instead of bare Python exceptions.
print_allowed=True
To allow or deny the student to print to stdout and stderr.
True: Prints are allowed (and displayed).None: Prints are allowed (but not displayed).False: Prints are disallowed (and displayed).
In all cases you can read what they printed using the value of the context manager:
with student_code(print_allowed=None) as run:
their_function()
assert run.err == ""
assert run.out == "42"
Good practices
Write the student checking code a you would write unit test for your own code.
Metadata
Release files for correction-helper 2026.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| correction_helper-2026.3.tar.gz | 12.6 kB | Without provenance | Details for correction_helper-2026.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| correction_helper-2026.3-py3-none-any.whl | Python 3 | none | any | Details for correction_helper-2026.3-py3-none-any.whl |
Total release size: 22.3 kB
Release files / correction_helper-2026.3.tar.gz
| Download URL | correction_helper-2026.3.tar.gz |
|---|---|
| Size | 12.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8aaa369b4ed65b98e7ca90b3ce83c370a434383c600532cfdcaa869d4f29dade
|
|
BLAKE2b-256 checksum How to use checksums |
f3d92e051327bf48c2e0d918dfd6691cc5c5cbd2d41dca9a4bfa011f1e7d435f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / correction_helper-2026.3-py3-none-any.whl
| Download URL | correction_helper-2026.3-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03340f2397b18caa72dcfa02c7e0f6993d3d52a692aa213f30e6c2410fe6b10e
|
|
BLAKE2b-256 checksum How to use checksums |
00e55c184a6cd84768565478cb046ecbd9f7df79ab0812b7e016f6e2d10400ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for correction-helper 2026.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.