jupyter-python-tutor

Domain: Real Packages

🎯 Motivation

jupyter-python-tutor brings Python Tutor-style step-by-step visualization to JupyterLab. Students see how variables change, how lists grow, how function calls stack, and SVG pointer arrows from frame variables to heap objects β€” all inline in the notebook cell. It is the Jupyter-embedded companion to OPT_Mentor, the browser-based visualizer.

πŸ“‹ Concrete Example

%%pytutor
x = 3
y = x + 4
print(y)

Install with pip install jupyter-python-tutor, then load with %load_ext jupyter_python_tutor. Use the %%pytutor cell magic β€” the extension uses Python’s sys.settrace to trace execution and renders an interactive slider-based visualization. Pure Python, no compiled extensions, works in CPython 3.8+.

πŸ”— Analogy

Like an X-ray machine for your code β€” you see the bones (structure), the blood flow (data moving through variables), and the heartbeat (execution loop) all at once, without cutting anything open. The slider lets you freeze time at any moment.

πŸ”— Connection to OPT_Mentor

OPT_Mentor is the companion web app β€” a serverless Python visualizer that runs entirely in the browser using Pyodide (Python compiled to WebAssembly). Visit https://dive4dec.github.io/OPT_Mentor/ to try it without installing anything. OPT_Mentor also features Socratic AI hints β€” instead of giving direct answers, it asks guiding questions using a fine-tuned LLM. While jupyter-python-tutor runs inside JupyterLab using CPython’s trace, OPT_Mentor runs in any browser using Pyodide β€” both produce the same style of step-by-step visualization.