Skip to content

Latest commit

 

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Code Visualizer

A local, in-browser tool for stepping through Python code execution and watching program state change — with trees, recursion, and linked lists rendered as actual trees/chains/graphs instead of Python Tutor's flat boxes-and-arrows.

Setup

pip install -r requirements.txt
python app.py

Windows note: the bare python command may resolve to the Microsoft Store's app-execution-alias stub instead of a real interpreter. If python app.py does nothing or opens the Store, use the Python launcher instead:

py app.py

Then open http://127.0.0.1:5000 in your browser.

Running tests

pytest

How it works

  • tracer.py uses sys.settrace to step through your code line-by-line, capturing the full call stack and all local variables at each step, with a unique call_id assigned to every function invocation so recursive calls can be told apart.
  • app.py is a small Flask server with one real endpoint, POST /run, that executes your pasted code through the tracer and returns the full list of steps as JSON.
  • The frontend (Preact + htm, no build step, loaded straight from a CDN as ES modules) replays those steps, letting you scrub back and forth, and renders linked lists/trees/recursive call graphs with D3.

This is a local-only tool — it runs your own code with a bare exec(), on your own machine, exactly like running a REPL. There's no sandboxing and it isn't meant to be hosted publicly.

Demo

[Add a demo GIF/video link here.]

License

MIT — see LICENSE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages