+ 1

Pdb debugging in Python

Hi, Can anyone explain me where to use pdb in python ? Is it a best method to debug in python ? If anyone have a good courses or vedeo that explain it. Thank you in advance

20th Jun 2023, 3:44 PM
Toufik Hammad
Toufik Hammad - avatar
7 Antworten
+ 4
https://realpython.com/JUMP_LINK__&&__python__&&__JUMP_LINK-debugging-pdb/ I usually just use VSCode debugger feature instead of pdb, it is really easy to visually set breakpoints, and check the variables in memory while stepping through the code, or occasionally evaluating an expression in the command line. Another alternative is using Python shell REPL to try things interactively, or even use IDLE, the built in editor that comes bundled with CPython. https://realpython.com/python-repl/ https://realpython.com/python-idle/
20th Jun 2023, 7:43 PM
Tibor Santa
Tibor Santa - avatar
+ 3
Debugging is not meant to make your code bigger. Its purpose is for you to find and fix errors easier. "Heavy" is not really a good word. You can also use other ways to ensure your code is correct, particularly writing unit tests. This doesnot replace the process of debugging, but complements it.
20th Jun 2023, 9:24 PM
Tibor Santa
Tibor Santa - avatar
+ 3
ayrad izem you don't need to import pdb at the top of your code. just add breakpoint() in the part of the code you want to inspect. This does the same thing as import pdb;pdb.set_trace() it is easier to remove or comment out if you no longer need it. https://www.geeksforgeeks.org/debugging-JUMP_LINK__&&__python__&&__JUMP_LINK-code-using-breakpoint-and-pdb/
21st Jun 2023, 2:49 AM
Bob_Li
Bob_Li - avatar
+ 1
Bob_Li thank you
21st Jun 2023, 9:20 AM
Toufik Hammad
Toufik Hammad - avatar
0
@Tibor Santa thank you If I use module bdp it means I will use more code and the program will be more heavy ??
20th Jun 2023, 9:05 PM
Toufik Hammad
Toufik Hammad - avatar
0
Tibor Santa I means when I import module pdb into my code , then my code will be more complexe than if I will use debugging built in my Pycharm for exemple ?
20th Jun 2023, 9:56 PM
Toufik Hammad
Toufik Hammad - avatar
22nd Jun 2023, 3:39 AM
Nitesh Sharma