In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "what is the breakpoint of the Pycharm debugger". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what is the breakpoint of the Pycharm debugger.
1. Preparatory work
(1) Pycharm version 3.0 or higher
(2) at least one Python interpreter is installed
(3) A Python project has been created
(4) using Debugger tutorial to debug an instance
2. What is a breakpoint
Pycharm provides many different types of breakpoint types of breakpoints, all with a specific icon icon. In this tutorial, we will cover line breakpoints in detail, marking a line of code to be suspended.
3. Breakpoint attribute
There are two ways to browse and change code properties:
(1) first of all, there is a separate top window to display breakpoint properties.
(2) there is a breakpoint dialog box Breakpoints dialog to display all breakpoints and their properties that exist in the current application.
4. Set breakpoints
Select the corresponding line of code, and then perform the following steps (choose one of the two):
(1) Click the blank slot on the left
(2) Press the Ctrl+F8 shortcut key
This is a trigger switch operation, that is, the operation can be repeated over and over again to remove / add breakpoints.
As an exercise, set a breakpoint on line 16:
5. Browse and change breakpoint properties
To browse the properties of a single breakpoint, simply right-click it:
6. Enable and close breakpoints
First, clear the Line 16 in ThreadSample.py enabled option in the check box, where the breakpoint will fail and the center of the icon will turn green:
OK, check the check box again, the icon will return to its original state, and the breakpoint will take effect.
7. Conditional code suspension
Suppose you want Pycharm to suspend only one thread at the current code, while other threads can pass through the breakpoint normally. The operation is very simple, just add a condition to the breakpoint:
Next, let's start script debugging (click the button in the toolbar), and you'll see that Pycharm actually only suspends Thread-7 at the current breakpoint, and Thread-6 passes that breakpoint normally:
8. How to ignore some breakpoints?
Usually, you just need to stop at one breakpoint and hope to pass through the other breakpoints. In other words, we don't want the Pycharm to stop at the breakpoint, but we still need to keep the corresponding breakpoint as a marker. How do we do that?
Uncheck the Suspend check box in the dialog box, and more details will be displayed in the breakpoint properties dialog box:
Check two options:
(1) Log messages to console: when this option is selected, Pycharm will display important information on the console after hitting the breakpoint.
(2) Log evaluated expressions: when this option is selected, Pycharm evaluates the specific expression given in the input box below and displays it on the console.
By the way, Pycharm also provides spelling prompts (Ctrl+ spaces) when entering expressions in the download input box. OK, rerun debugging, and Pycharm will display the following information in the debugging console:
Basic information about the application.
Registration information when the breakpoint is hit
The evaluation result of the expression
9. Browse all breakpoints
All the breakpoint-related dialogs you use above can help you get most of the important information about breakpoints. However, we usually use the Breakpoints dialog dialog box to do most of the breakpoint processing, which displays the property information of all breakpoints in the current project and makes it easier for us to change them.
We can open this dialog box in the following ways:
(1) Ctrl+Shift+F8 shortcut key
(2) Select Run → View Breakpoints in the main menu
(3) Click More (Ctrl+Shift+F8) in the breakpoint properties shortcut dialog box.
(4) Click the button in the debug window.
10. Create a temporary breakpoint
Suppose you want a breakpoint where Pycharm deletes the breakpoint after hitting it. Pycharm provides a special complex option, Remove once hit, which is not enabled by default.
The add Suspend check box has been selected, then select the Remove once hit check box to observe the change of the breakpoint icon:
Redebug and find that Pycharm pauses only once at the breakpoint and then removes it to ensure that subsequent program execution is not blocked:
At this point, I believe you have a deeper understanding of "what is the breakpoint of the Pycharm debugger". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.