Debugging 101

https://github.com/microsoft/vscode-recipes/tree/master/debugging%20python

We need VSC, Python extension and a launch.json with the minimum of integrated and external.

Click on the Debugging icon in the Activity Bar to bring up the Debug view.

Then click on the gear icon to configure a launch.json file, select Launch for the environment. (Some .Net software will be installed)

Select the py file to open the configuration or launch.json

The launch.json Debug->Open configurations

For basic Python debugging of files, you will only need the following configuration:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File (Integrated Terminal)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        },
        {
            "name": "Python: Current File (External Terminal)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "externalTerminal"
        }
    ]
}

Ok, let’s run a script and test it.

Start Debugging.

1 Open your Python file in VS Code.

2 Go to the Debug view, select the Start Debugging then press F5 or click the green play button.

3 VS Code should now show the rails server logs.

4 Go ahead and set a breakpoint in any of the files by clicking on the space before the line number. A red dot should appear to show a breakpoint.

6 Press F5 to start debugging.

7 Your breakpoint should now be hit.

8 To continue, press F10 again (F5 is for run, F10 is for step into)

Here we see the numbers from total after moving over the breakpoint.

To finish the debugging mode, press F5 for run og step into with F10.