Step through the program
Stepping is the process of controlling step-by-step execution of the program.
PyCharm provides a set of stepping actions, which are used depending on your strategy (for example, whether you need to go directly to the next line or enter the methods invoked on your way there).
The stepping buttons are located on the Debug window toolbar.
Step over
Steps over the current line of code and takes you to the next line even if the highlighted line has method calls in it. The implementation of the methods is skipped, and you move straight to the next line of the caller method.
Click the Step Over button or press F8.
If there are breakpoints inside the skipped methods, the debugger will stop at them. To skip any breakpoints on the way, use Force step over.
Step into
Steps into the method to show what happens inside it. Use this option when you are not sure the method is returning a correct result.
Click the Step Into button or press F7.
If there are several method calls on the line, PyCharm asks you which method to enter. This feature is called Smart step into.
By default, smart step into is used every time when there are multiple method calls on the line. If you do not want to use it automatically, go to Always do smart step into checkbox.
and clear the Some scripts are skipped by Step into as you normally might not need to debug them. This list can be fine-tuned on the page of the Settings dialog (Control+Alt+S). In the Settings dialog (Control+Alt+S), go to . The Debugger. Stepping page opens. To skip all library scripts, select the Do not step into library scripts checkbox. To suppress stepping into some specific scripts, select the Do not step into scripts checkbox and create a list of such scripts using the toolbar buttons.
Step into my code
When debugging, you might want to concentrate on your own code and prevent debugger from stepping into library classes.
Click the Step Into My Code button (Alt+Shift+F7).
Smart step into
Smart step into is helpful when there are several method calls on a line, and you want to be specific about which method to enter. This feature allows you to select the method call you are interested in.
From the main menu, select
or press Shift+F7.Click the method. You can also select it using the arrow keys or tabs and press Enter/F7.
By default, smart step into is used every time when there are multiple method calls in the line. If you do not want to use it automatically, go to Always do smart step into checkbox.
and clear theStep out
Steps out of the current method and takes you to the caller method.
Click the Step Out button or press Shift+F8.
Run to cursor
Continues the execution until the position of the caret is reached.
Place the caret at the line where you want the program to pause.
Click the Run to Cursor button or press Alt+F9.
Also, you can Run to Cursor by clicking the line number in the gutter.
You can configure whether you want Run to Cursor to work on clicking a line number in .
To skip any breakpoints on the way, use Force run to cursor.
Force step into
Steps in the method even if this method is skipped by the regular Step Into.
Click the Force step into button or press Alt+Shift+F7.
Force run to cursor
Continues the execution until the position of the caret is reached. All breakpoints on the way are ignored.
Place the caret at the line where you want the program to pause.
From the main menu, select
or press Control+Alt+F9.
Force step over
Steps over the current line of code and takes you to the next line even if the highlighted line has method calls in it. If there are breakpoints in the called methods, they are ignored.
From the main menu, select
or press Alt+Shift+F8.
When a breakpoint is reached or your program is suspended, the Debug tool window becomes active and enables you to get control over the program's execution. For this purpose, you can use the Run menu commands, or the icons on the stepping toolbar of in the Debug tool window.
Each stepping action advances the execution point to the next execution location, depending on the action you choose.
Jump to cursor
Stops the execution and jumps to the line where the caret is. All breakpoints on the way are ignored.
Place the caret at the line where you want the program to pause.
Right-click and select
from the context menu.