Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
So You Think You Can PDB?
Clayton Parker - PyOhio 2014
So You Think You Can PDB? - Clayton Parker - PyOhio 2014
Who am I?
Director of Development at Six Feet Up
claytron on the internets
So You Think You Can PDB? - Clayton Parker - Py...
What is PDB?
Interactive debugging tool
Pure awesome
So You Think You Can PDB? - Clayton Parker - PyOhio 2014
How to invoke it?
Set a trace directly in the code:
import pdb; pdb.set_trace()
Or start a script with pdb directly:
$ pyt...
Now what?
Common commands
Navigating the stack
So You Think You Can PDB? - Clayton Parker - PyOhio 2014
Help
Type help or ? for short to know what commands are available
Further help on commands help help or help list
So You T...
Show the current context
Type list or l to see the current position in the code
So You Think You Can PDB? - Clayton Parker...
Repeating the last command
Just type return
So You Think You Can PDB? - Clayton Parker - PyOhio 2014
Examine variables
Type print or p to see what a variable is set to
Use pp to pretty print the result for easier reading
So...
Go to the next line
Type next or n to go to the next line
So You Think You Can PDB? - Clayton Parker - PyOhio 2014
Step into a function
Type step or s to step into a function for further inspection
So You Think You Can PDB? - Clayton Par...
Skip over a loop
Type until or u to skip over the end of a loop
So You Think You Can PDB? - Clayton Parker - PyOhio 2014
Skip to the end of a function
Type return or r to go to the end of a function
So You Think You Can PDB? - Clayton Parker -...
Breakpoints
Type break or b to see a list of breakpoints
Then b and a line number to set one
To clear out a breakpoint cle...
Continue execution
Type continue or c to go to the next breakpoint or finish
execution
So You Think You Can PDB? - Clayton...
Conditional breakpoints
Breakpoints can take an expression to know when to break:
b 11, this_year == 2014
So You Think You...
See where you are in the
stack
Type where or w to see the current stack
You can debug at any point in the stack
So You Thi...
Traverse the stack
Type up or u to go up the stack
Type down or d to go back down the stack
So You Think You Can PDB? - Cl...
New features in Python 3:
Interact
Type interact to open an interpreter in the current scope
So You Think You Can PDB? - C...
New features in Python 3:
Long list
Type longlist or ll to show the complete current function
So You Think You Can PDB? - ...
All done
Type quit or q to exit pdb and stop execution
So You Think You Can PDB? - Clayton Parker - PyOhio 2014
PDB Alternatives
PDB++
ipdb
rpdb / remote-pdb
So You Think You Can PDB? - Clayton Parker - PyOhio 2014
Helpers
PdbSublimeTextSupport
vimpdb
flake8-debugger
So You Think You Can PDB? - Clayton Parker - PyOhio 2014
.pdbrc
Personalize your experience
Set up aliases / custom mappings
Enhance with readline support
So You Think You Can PDB...
Links
Python Module of the Week: PDB
In Depth PDB - Nathan Yergler
So You Think You Can PDB? - Clayton Parker - PyOhio 2014
Upcoming SlideShare
Loading in …5
×

So you think you can pdb?

1,229 views

Published on

An intro to using PDB. Overview and example usage of all the basic commands.

Published in: Technology
  • Be the first to comment

So you think you can pdb?

  1. 1. So You Think You Can PDB? Clayton Parker - PyOhio 2014 So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  2. 2. Who am I? Director of Development at Six Feet Up claytron on the internets So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  3. 3. What is PDB? Interactive debugging tool Pure awesome So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  4. 4. How to invoke it? Set a trace directly in the code: import pdb; pdb.set_trace() Or start a script with pdb directly: $ python -m pdb example.py It is that easy! So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  5. 5. Now what? Common commands Navigating the stack So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  6. 6. Help Type help or ? for short to know what commands are available Further help on commands help help or help list So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  7. 7. Show the current context Type list or l to see the current position in the code So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  8. 8. Repeating the last command Just type return So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  9. 9. Examine variables Type print or p to see what a variable is set to Use pp to pretty print the result for easier reading So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  10. 10. Go to the next line Type next or n to go to the next line So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  11. 11. Step into a function Type step or s to step into a function for further inspection So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  12. 12. Skip over a loop Type until or u to skip over the end of a loop So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  13. 13. Skip to the end of a function Type return or r to go to the end of a function So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  14. 14. Breakpoints Type break or b to see a list of breakpoints Then b and a line number to set one To clear out a breakpoint clear or cl and a breakpoint number So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  15. 15. Continue execution Type continue or c to go to the next breakpoint or finish execution So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  16. 16. Conditional breakpoints Breakpoints can take an expression to know when to break: b 11, this_year == 2014 So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  17. 17. See where you are in the stack Type where or w to see the current stack You can debug at any point in the stack So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  18. 18. Traverse the stack Type up or u to go up the stack Type down or d to go back down the stack So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  19. 19. New features in Python 3: Interact Type interact to open an interpreter in the current scope So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  20. 20. New features in Python 3: Long list Type longlist or ll to show the complete current function So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  21. 21. All done Type quit or q to exit pdb and stop execution So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  22. 22. PDB Alternatives PDB++ ipdb rpdb / remote-pdb So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  23. 23. Helpers PdbSublimeTextSupport vimpdb flake8-debugger So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  24. 24. .pdbrc Personalize your experience Set up aliases / custom mappings Enhance with readline support So You Think You Can PDB? - Clayton Parker - PyOhio 2014
  25. 25. Links Python Module of the Week: PDB In Depth PDB - Nathan Yergler So You Think You Can PDB? - Clayton Parker - PyOhio 2014

×