MCPcopy Index your code
hub / github.com/datacamp/pythonwhat

github.com/datacamp/pythonwhat @v2.30.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.30.1 ↗ · + Follow
701 symbols 2,151 edges 71 files 82 documented · 12%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

pythonwhat

Build Status PyPI version Documentation Status FOSSA Status

Verify Python code submissions and auto-generate meaningful feedback messages. Originally developed for Python exercises on DataCamp for so-called Submission Correctness Tests, but can also be used independently.

  • New to teaching on DataCamp? Check out https://instructor-support.datacamp.com
  • To learn what SCTs are and how they work, visit this article specifically.
  • For a complete overview of all functionality inside pythonwhat and articles about what to use when, consult https://pythonwhat.readthedocs.io.

Installation

# latest stable version from PyPi
pip install pythonwhat

# latest development version from GitHub
pip install git+https://github.com/datacamp/pythonwhat

Demo

To experiment locally, you can use setup_state() and write SCTs interactively. The code throws an error when the underlying checks fail.

# make all checking functions available
from pythonwhat.test_exercise import prep_context
_, ctxt = prep_context()
globals().update(ctxt)

# initialize state with student and solution submission
from pythonwhat.test_exercise import setup_state
setup_state(stu_code = "x = 5", sol_code = "x = 4")

Ex().check_object('x')
# No error: x is defined in both student and solution process

Ex().check_object('x').has_equal_value()
# TestFail: Did you correctly define the variable `x`? Expected `4`, but got `5`.

# Debugging state
Ex()._state               # access state object
dir(Ex()._state)          # list all elements available in the state object
Ex()._state.student_code  # access student_code of state object

To learn how to include an SCT in a DataCamp course, visit https://instructor-support.datacamp.com.

Run tests

pyenv local 3.12.7
pip3.12 install -r requirements-test.txt
pip3.12 install -e .
pytest

Contributing

Bugs? Questions? Suggestions? Create an issue, or contact us!

License

FOSSA Status

Core symbols most depended-on inside this repo

run
called by 173
pythonwhat/local.py
update
called by 21
pythonwhat/parsing.py
check_part
called by 18
pythonwhat/checks/check_funcs.py
find
called by 15
pythonwhat/State.py
parse
called by 14
pythonwhat/State.py
get_env
called by 13
pythonwhat/tasks.py
visit_each
called by 12
pythonwhat/parsing.py
check_args
called by 10
pythonwhat/checks/check_funcs.py

Shape

Function 468
Method 177
Class 47
Route 9

Languages

Python100%

Modules by API surface

pythonwhat/parsing.py121 symbols
tests/test_spec.py39 symbols
tests/test_messaging.py38 symbols
tests/test_check_function.py32 symbols
pythonwhat/local.py32 symbols
tests/test_author_warnings.py30 symbols
pythonwhat/tasks.py30 symbols
pythonwhat/State.py27 symbols
pythonwhat/probe.py25 symbols
pythonwhat/Test.py24 symbols
tests/test_check_object.py19 symbols
tests/test_check_try_except.py17 symbols

For agents

$ claude mcp add pythonwhat \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact