PyCharm lets you create breakpoints of several types. Each of the breakpoint types supported by PyCharm addresses different debugging needs and has its own individual settings.
Breakpoints are triggered when the program reaches the specified line of source code, before it is executed. The line of code that contains a set breakpoint, is marked with a red stripe; once such line of code is reached, the marking stripe changes to blue.
Once set, a breakpoint remains in project until removed. Breakpoints can only be set on executable lines of code. Comments, declarations of methods, and empty lines are not valid locations for breakpoints.
If a file with breakpoints has been modified externally, for example, updated from a version control repository, or changed in an external editor, so that line numbers are changed, then the breakpoints will be moved accordingly.
It is important to note that PyCharm should be running at the moment of such modification; otherwise, such changes will pass unnoticed.
In this section:
- Python Line Breakpoint
- Temporary Line Breakpoints
- Django Line Breakpoints
- Exception Breakpoint
Python Line Breakpoint
These breakpoints are assigned to the lines of source code and are used to target a particular section for debugging.
Temporary line breakpoints
These breakpoints are assigned to the lines of source code and are used to target a particular section for debugging. When hit, such breakpoints are immediately removed.
Django Line Breakpoints
These breakpoints are assigned to the lines of the Django templates, and can only be set on the lines that contain Django tags. Plain HTML lines in Django templates are not valid location for the Django line breakpoints.
Django line breakpoints are triggered when the corresponding tags are rendered by the Django template engine. Refer to the section Debugging Django Templates for details.
Exception breakpoints are triggered when the specified exception is thrown. Unlike the line breakpoints, which require specific source references, exception breakpoints apply globally to the exception condition, rather than to a particular code reference.
Depending on the type of processing an exception, the debugging can break when a process terminates with an exception, or as soon as an exception occurs.
Django exception breakpoints enable suspending the program execution when a Django template error occurs (exceptions TemplateDoesNotExist orVariableDoesNotExist), if such a breakpoint is enabled in the Django exception breakpoints tab of the Breakpoints dialog.