Using the Visualizer

The visualizer is a feature designed to help understand how a Python program is working at a more basic level.  It let's you see what the python interpreter is doing as it steps through your program, such as variables being assigned, objects being created, etc.

Generally, the visualizer is a good tool to use if you have simpler scripts that you'd like to understand.  Some of the questions it will help you with are: "How does recursion work?", "How does a function call work?", "How do various methods, such as append, work when working with lists?".

Starting the visualizer


In order to start the visualizer, open a python script that you're able to run.  In the menu, there will be a link with the title "Visualize".  Click the "Visualize" link.
Once you've clicked the link, it will take from a couple of seconds, to a few minutes to load, depending on what your python script is doing.  Something simple, like lighting a few LED's, or printing out a few lines will load very quickly.  One thing to watch out for is that you don't have any infinite loops in your code, such as if you have a script that is designed to just keep running while periodically checking the temperature.

The next screen you'll see is the following:
The toolbar (#1) allows you to step through your program.  You can navigate any way you'd like, forward, back, and jump to the start, or end.

The code (#2) is listed to the left.  As you step through your program, you'll see two arrows in the left gutter that will show you what line has just executed (green), and what will be executing once you click "Forward" (red).

The right column displays the stack (#3) as your program executes.  You'll see your variables getting assigned, objects being created, etc.

The bottom pane is your program output (#4).  Anytime you have a print statement, or any other type of output, you'll see it displayed in this section.

Here is a screen shot of how it looks while stepping through a program:
One thing to note about the visualizer is that it runs your entire script on the server, then sends the playback of your script to the WebIDE.  It's not a real-time debugger (but the WebIDE has one of those as well!).  For example, if you have an LED that lights up in your program, it will light up quick and then send back the response, and when you step through your program, the LED won't light up as it has already run.

Credit to the visualizer is given to Philip Guo at pythontutor.com. We forked, tweaked, converted, and modified his open source creation to work as a streamlined feature within the WebIDE.
Last updated on 2015-05-04 at 04.27.26 PM Published on 2012-10-05 at 01.21.56 PM