1 / 6

Debuggers in Python

Debuggers in Python. The Debugger. Every programming IDE has a tool called a debugger. This application does NOT locate or fix your bugs for you! It slows the program down by letting you ‘single-step’ through it You can check your understanding of the code as it goes by

angelo
Télécharger la présentation

Debuggers in Python

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Debuggers in Python

  2. The Debugger • Every programming IDE has a tool called a debugger. • This application does NOT locate or fix your bugs for you! • It slows the program down by letting you ‘single-step’ through it • You can check your understanding of the code as it goes by • It shows you the variables that are created and their values • It shows you the call stack of function calls that have been done

  3. Breakpoints • In order to step through your program one statement at a time, you must first set a breakpoint. • If your program is a straight sequence, you may need only one. • If you have branches and loops, you may need several to make sure the execution does actually hit one. • When the program is running under the Debugger, it will run normally (at normal speed) until a breakpointed statement is about to execute. Then the interpreter gives control to you the programmer, it pauses the program and shows the current state of the program.

  4. Stepping • Step Over (Over in IDLE) • “the next statement to execute has a function call in it, I do NOT want to see the details of that call. Just do the call and pause at the next statement” • Step Into (Step in IDLE) • “The next statement to execute has a function call in it, I DO want to see the details of that call. Get to the top of the function definition and pause” • Step Out of (Out in IDLE) • “I have stepped into a function which I did not meant to. Please finish the function call quickly and then pause”

  5. Watch window • For your debugger, check to see where the watch window is • That is where the variables are shown as they are defined and destroyed • Their value is shown, usually their type • When you step through a statement, watch this window to see how a variable changes • In IDLE the window is labeled “Locals” • In WingIDE it is labeled “Stack Data”

  6. Call stack • This keeps track of the current function call • In WingIDE it is a window usually to the right which grows downward as more functions are called • In IDLE it is the list of statements that is in the main Debug window, it also grows downward as more functions are called – it is NOT labeled “call stack”

More Related