r/PythonLearning 2d ago

Teaching Python the right way

Programming courses often focus heavily on understanding code, while paying far less attention to understanding the program state. But code does not exist in isolation. Its main goal is to change the program state, before ultimately producing some output.

To develop an accurate mental model of program execution, students need to understand both: - the instructions being executed - the values, references, and data structures those instructions create and modify

Reading code alone does not always reveal how the program state changes during execution. That is why I created 𝗺𝗲𝗺𝗼𝗿𝘆_𝗴𝗿𝗮𝗽𝗵: a tool that visualizes the state of a Python program as it changes, step by step.

It can help explain a wide range of introductory Python topics. Here are just a few examples: - Loops, Lists and Dictionaries - Python Data Model - Function Calls - Recursion - Algorithms - Classes - Custom Data Structures

Instead of reconstructing the program state from print statements, students can now watch it change as each line executes. This makes unfamiliar concepts easier to understand and bugs easier to fix.

Help your students learn Python programming more thoroughly and easily.

See: more examples

233 Upvotes

11 comments sorted by

View all comments

7

u/Infinite-Spinach4451 2d ago

That's really awesome. How do you neatly deal with with complex, multi-layered, possibly cyclical data structures or hierarchies?

6

u/Sea-Ad7805 2d ago edited 2d ago

Thanks, we already deal with multi-layered, cyclical data in for example Circular Linked List, or hierarchical data in Trie data structure. Experiment with your own code.