Skip to content

Commit

Permalink
Small edits to Python tutorial debugging section
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaPartlow committed Sep 6, 2019
1 parent a51935e commit daca3e3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions docs/python/python-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,17 @@ Let's now try debugging our simple Hello World program.

First, set a breakpoint on line 2 of `hello.py` by placing the cursor on the `print` call and pressing `kb(editor.debug.action.toggleBreakpoint)`. Alternately, just click in the editor's left gutter, next to the line numbers. When you set a breakpoint, a red circle appears in the gutter.

Next, to initialize the debugger, press `kb(workbench.action.debug.start)`. Since this is your first time debugging this file, a configuration menu will open from the Command Palette, allowing you to select the type of debug configuration you would like for the opened file.
![Setting a breakpoint in hello.py](images/tutorial/breakpoint-set.png)

Next, to initialize the debugger, press `kb(workbench.action.debug.start)`. Since this is your first time debugging this file, a configuration menu will open from the Command Palette allowing you to select the type of debug configuration you would like for the opened file.

![Debug configurations after launch.json is created](images/tutorial/debug-configurations.png)

**Note**: VS Code uses JSON files for all of its various configurations; `launch.json` is the standard name for a file containing debugging configurations.

These different configurations are fully explained in [Debugging configurations](/docs/python/debugging.md); for now, just select **Python File**, which is the configuration that runs the current file shown in the editor using the currently selected Python interpreter. Once selected the Python extension creates a `launch.json` file within a `.vscode` folder (located in the folder's root directory) that contains a pre-defined configuration based on your selection (you can also learn more about this file in [Debugging configurations](/docs/python/debugging.md)).

The debugger stops at the first line of the file breakpoint. The current line is indicated with a yellow arrow in the left margin. If you examine the **Local** variables window at this point, you will see now defined `msg` variable appears in the **Local** pane.
The debugger will stop at the first line of the file breakpoint. The current line is indicated with a yellow arrow in the left margin. If you examine the **Local** variables window at this point, you will see now defined `msg` variable appears in the **Local** pane.

![Debugging step 2 - variable defined](images/tutorial/debug-step-02.png)

Expand All @@ -171,9 +173,9 @@ A debug toolbar appears along the top with the following commands from left to r

The Status Bar also changes color (orange in many themes) to indicate that you're in debug mode. The **Python Debug Console** also appears automatically in the lower right panel to show the commands being run, along with the program output.

To continue running the program, select the continue command on the debug toolbar (`kb(workbench.action.debug.start)`). The debugger runs the program to the end.
> **Tip** Debugging information can also be seen by hovering over code, such as variables. In the case of `msg`, hovering over the variable will display the string `Hello world` in a box above the variable.
To continue running the program, select the continue command on the debug toolbar (`kb(workbench.action.debug.start)`). The debugger runs the program to the end.

> **Tip** Debugging information can also be seen by hovering over code, such as variables. In the case of `msg`, hovering over the variable will display the string `Hello world` in a box above the variable.
You can also work with variables in the **Debug Console** (If you don't see it, select **Debug Console** in the lower right area of VS Code, or select it from the **...** menu.) Then try entering the following lines, one by one, at the **>** prompt at the bottom of the console:

Expand All @@ -187,7 +189,7 @@ msg.split()

Select the blue **Continue** button on the toolbar again (or press F5) to run the program to completion. "Hello World" appears in the **Python Debug Console** if you switch back to it, and VS Code exits debugging mode once the program is complete.

If you restart the debugger, the debugger again stops on the first breakpoint (or the first line is `stopOnEntry` is set to true, in which case the debugger stops before any code is run.)
If you restart the debugger, the debugger again stops on the first breakpoint (or the first line if `stopOnEntry` is set to true, in which case the debugger stops before any code is run.)

To stop running a program before it's complete, use the red square stop button on the debug toolbar (`kb(workbench.action.debug.stop)`), or use the **Debug > Stop debugging** menu command.

Expand Down

0 comments on commit daca3e3

Please sign in to comment.