r/pythontips • • Mar 24 '21

Python3_Specific How to debug in Python?

Please share some tips about the title.

32 Upvotes

38 comments sorted by

View all comments

7

u/Karam2468 Mar 24 '21

What does debugging do anyways? Newbie here. Why and when shoud we use it?

10

u/SHKEVE Mar 24 '21

It’s the process of “stepping through” code either in chunks or line by line and seeing what’s going on. Say you have a function that’s returning an unexpected value, you can go through each line of your function as it executes and watch what happens to your variables to catch where the error is.

3

u/VeritosCogitos Mar 24 '21 edited Mar 24 '21

Have you used bugged code? Where you expect one result and get another?

Is that what you want to produce?

The more frequently you test your code to make sure it works is better than finishing a project and finding nothing works and need to narrow it down.

Any typo can cause a bug, and sometimes the bug checkers won’t even catch that. My least favorite debugging error is syntax error with no clue where the error takes place lol.

1

u/[deleted] Mar 25 '21

"debugging" de-bugging, bugs are errors in our code (if there are errors your code does not run, it just stops abruptly due to that error). de - means to remove and bugging - refers to bugs, so it literally means to remove bugs, removing errors in our code is called debugging