SlideShare a Scribd company logo
Python Debuggers
About these slides
These slides roughly correspond to a talk I
gave at a DC Python meetup on 2014-04-01.
During the actual talks I live-coded rather than
referring to slides, but wanted to make a
reference document for those that couldn’t
make it.
What’s a debugger?
Like a DVR for your program:
● pause at any time
● step through line by line
● inspect values
● execute code
Why do you need a debugger?
Debuggers are a powerful tool to help you
understand what your program is doing. They
are invaluable in tracking bugs, understanding
foreign code, and much more.
Print statements are not good enough
● You end up re-running your code countless
times inserting statements on random lines
● The output is unstructured and barely
intelligible
● Your codebase becomes littered with
accidentally committed debug statements
Debugging is easy!
Insert a breakpoint:
pdb.set_trace()
Start debugger after an exception:
pdb.pm() #post-mortem
PDB Commands
h(elp) - list commands or get help on a command
b(reak) - insert a breakpoint
c(ontinue) - keep running until you hit a breakpoint
s(tep) - continue until the next line executed (step into a function)
n(ext) - continue until the next line in the current function
r(eturn) - continue until the current function returns
For a full list of commands (with better explanaitons), use the help command or
consult the documentation
Upgrade to ipdb!
install: sudo pip install ipdb
usage: s/pdb/ipdb/
… and that’s it! It works very similar, but with a few
improvements:
● better context for traces
● colors
● more commands
● tab completion
Upgrade to wdb!
install: sudo pip install wdb
usage: s/pdb/wdb/
have to run the server in the background: wdb.server.py &
● Launches a browser window
○ great for situations where you don’t have access to the
terminal (like web servers) but can be used for any
program
● awesome interface (easily jump around the call stack)
● better tab completion
● can access from other machines
Making your own debugger
Extend bdb.Bdb and override the user_* functions
You can do whatever you want on function call/return,
exception, and line executed:
* write a profiler
* visualize your code execution
* make your ide smart about code usage: what functions
actually call this one when we run our code? How often is
this line executed?
My pet project
I’ve been writing a program that logs every line, function call, return, and
exception to a file with timestamps and other important metadata.
That part is working as a proof of concept (not terribly efficient)
I hope to write multiple programs that can read that output and help developers
better understand what their code is doing (what calls what, how long do things
take, visualize code coverage, step through programs after they’ve finished
running.
I hope to post an initial version of this to github very soon. If you’re interested
and want to talk, get updates, or help, please ping me on github/mattboehm or
boehm.matthew@gmail.com
Thanks! About me:
https://github.com/mattboehm
@mattboehm
Founder of the DC/NoVA Vim Meetup: http://bit.ly/dcvim
(I hope you can make it out to an event-- you’ll learn a lot no matter what your experience level)
Python/JS developer at Novetta Solutions
(I love my job-- talk to me if you’re looking for something new)
Talk to me any time about:
Vim, Python, AngularJS, Git, Linux, dvorak, mechanical/ergonomic keyboards, standing desks, meetups,
podcasts, board games, or anything else that strikes your fancy

More Related Content

What's hot

Adopting language server for apache camel feedback from a java/Eclipse plugi...
Adopting language server for apache camel  feedback from a java/Eclipse plugi...Adopting language server for apache camel  feedback from a java/Eclipse plugi...
Adopting language server for apache camel feedback from a java/Eclipse plugi...
Aurélien Pupier
 
A simple tool for debug (tap>)
A simple tool for debug (tap>)A simple tool for debug (tap>)
A simple tool for debug (tap>)
Laurence Chen
 
PHPUnit with Magento
PHPUnit with MagentoPHPUnit with Magento
PHPUnit with Magento
Tu Hoang
 
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
VincitOy
 
Tweakers Developers Summit 2019 - Angular for backend developers
Tweakers Developers Summit 2019 - Angular for backend developersTweakers Developers Summit 2019 - Angular for backend developers
Tweakers Developers Summit 2019 - Angular for backend developers
Bert Jan Schrijver
 
Code Quality
Code QualityCode Quality
Code Quality
François Camus
 
Go language presentation
Go language presentationGo language presentation
Go language presentation
paramisoft
 
Building Command Line Tools with Golang
Building Command Line Tools with GolangBuilding Command Line Tools with Golang
Building Command Line Tools with Golang
Takaaki Mizuno
 
Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016
Søren Lund
 
An introduction to go programming language
An introduction to go programming languageAn introduction to go programming language
An introduction to go programming language
Technology Parser
 
Oleksii Pedorenko and Dmytro Melnychuk "DAO Project Experience"
Oleksii Pedorenko and Dmytro Melnychuk "DAO Project Experience"Oleksii Pedorenko and Dmytro Melnychuk "DAO Project Experience"
Oleksii Pedorenko and Dmytro Melnychuk "DAO Project Experience"
LogeekNightUkraine
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016
Søren Lund
 
Introduction to Robot Framework (external)
Introduction to Robot Framework (external)Introduction to Robot Framework (external)
Introduction to Robot Framework (external)
Zhe Li
 
From git to forge
From git to forgeFrom git to forge
From git to forge
Nicolas Corrarello
 
Robot framework - Lord of the Rings
Robot framework - Lord of the RingsRobot framework - Lord of the Rings
Robot framework - Lord of the Rings
Asheesh Mehdiratta
 
J-Spring 2018 - Angular for Java developers
J-Spring 2018 - Angular for Java developersJ-Spring 2018 - Angular for Java developers
J-Spring 2018 - Angular for Java developers
Bert Jan Schrijver
 
Code Nomads meetup June 2018 - Angular for Java developers
Code Nomads meetup June 2018 - Angular for Java developersCode Nomads meetup June 2018 - Angular for Java developers
Code Nomads meetup June 2018 - Angular for Java developers
Bert Jan Schrijver
 
OpenValue meetup July 2018 - Angular for Java developers
OpenValue meetup July 2018 - Angular for Java developersOpenValue meetup July 2018 - Angular for Java developers
OpenValue meetup July 2018 - Angular for Java developers
Bert Jan Schrijver
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit TestingSøren Lund
 
Automation using RobotFramework for embedded device
Automation using RobotFramework for embedded deviceAutomation using RobotFramework for embedded device
Automation using RobotFramework for embedded device
Srix Sriramkumar
 

What's hot (20)

Adopting language server for apache camel feedback from a java/Eclipse plugi...
Adopting language server for apache camel  feedback from a java/Eclipse plugi...Adopting language server for apache camel  feedback from a java/Eclipse plugi...
Adopting language server for apache camel feedback from a java/Eclipse plugi...
 
A simple tool for debug (tap>)
A simple tool for debug (tap>)A simple tool for debug (tap>)
A simple tool for debug (tap>)
 
PHPUnit with Magento
PHPUnit with MagentoPHPUnit with Magento
PHPUnit with Magento
 
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
 
Tweakers Developers Summit 2019 - Angular for backend developers
Tweakers Developers Summit 2019 - Angular for backend developersTweakers Developers Summit 2019 - Angular for backend developers
Tweakers Developers Summit 2019 - Angular for backend developers
 
Code Quality
Code QualityCode Quality
Code Quality
 
Go language presentation
Go language presentationGo language presentation
Go language presentation
 
Building Command Line Tools with Golang
Building Command Line Tools with GolangBuilding Command Line Tools with Golang
Building Command Line Tools with Golang
 
Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016
 
An introduction to go programming language
An introduction to go programming languageAn introduction to go programming language
An introduction to go programming language
 
Oleksii Pedorenko and Dmytro Melnychuk "DAO Project Experience"
Oleksii Pedorenko and Dmytro Melnychuk "DAO Project Experience"Oleksii Pedorenko and Dmytro Melnychuk "DAO Project Experience"
Oleksii Pedorenko and Dmytro Melnychuk "DAO Project Experience"
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016
 
Introduction to Robot Framework (external)
Introduction to Robot Framework (external)Introduction to Robot Framework (external)
Introduction to Robot Framework (external)
 
From git to forge
From git to forgeFrom git to forge
From git to forge
 
Robot framework - Lord of the Rings
Robot framework - Lord of the RingsRobot framework - Lord of the Rings
Robot framework - Lord of the Rings
 
J-Spring 2018 - Angular for Java developers
J-Spring 2018 - Angular for Java developersJ-Spring 2018 - Angular for Java developers
J-Spring 2018 - Angular for Java developers
 
Code Nomads meetup June 2018 - Angular for Java developers
Code Nomads meetup June 2018 - Angular for Java developersCode Nomads meetup June 2018 - Angular for Java developers
Code Nomads meetup June 2018 - Angular for Java developers
 
OpenValue meetup July 2018 - Angular for Java developers
OpenValue meetup July 2018 - Angular for Java developersOpenValue meetup July 2018 - Angular for Java developers
OpenValue meetup July 2018 - Angular for Java developers
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit Testing
 
Automation using RobotFramework for embedded device
Automation using RobotFramework for embedded deviceAutomation using RobotFramework for embedded device
Automation using RobotFramework for embedded device
 

Similar to Python debuggers slides

Autotools, Design Patterns and more
Autotools, Design Patterns and moreAutotools, Design Patterns and more
Autotools, Design Patterns and more
Vicente Bolea
 
Ice breaker with dev ops
Ice breaker with dev opsIce breaker with dev ops
Ice breaker with dev ops
Mukta Aphale
 
icebreakerwithdevops-150218112943-conversion-gate02
icebreakerwithdevops-150218112943-conversion-gate02icebreakerwithdevops-150218112943-conversion-gate02
icebreakerwithdevops-150218112943-conversion-gate02Manohar Kumar
 
Programming tools for developers
Programming tools for developersProgramming tools for developers
Programming tools for developers
BBVA API Market
 
Using Delphi as a no code development environment
Using Delphi as a no code development environmentUsing Delphi as a no code development environment
Using Delphi as a no code development environment
pprem
 
Github developing stack
Github developing stackGithub developing stack
Github developing stack
Vicente Bolea
 
The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189
Mahmoud Samir Fayed
 
Introduction of Tools for providing rich user experience in debugger
Introduction of Tools for providing rich user experience in debuggerIntroduction of Tools for providing rich user experience in debugger
Introduction of Tools for providing rich user experience in debugger
Naoto Ono
 
Introducing Yeoman 1.0 beta
Introducing Yeoman 1.0 betaIntroducing Yeoman 1.0 beta
Introducing Yeoman 1.0 betadigitalzombie
 
Frameworkless CLI app in PHP
Frameworkless CLI app in PHPFrameworkless CLI app in PHP
Frameworkless CLI app in PHP
Max Bodnar
 
What is dev ops?
What is dev ops?What is dev ops?
What is dev ops?
Mukta Aphale
 
IDE and Toolset For Magento Development
IDE and Toolset For Magento DevelopmentIDE and Toolset For Magento Development
IDE and Toolset For Magento Development
Abid Malik
 
Indy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-muleIndy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-mule
ikram_ahamed
 
DevOps Workshop Part 1
DevOps Workshop Part 1DevOps Workshop Part 1
DevOps Workshop Part 1
GDSC UofT Mississauga
 
The Ring programming language version 1.2 book - Part 4 of 84
The Ring programming language version 1.2 book - Part 4 of 84The Ring programming language version 1.2 book - Part 4 of 84
The Ring programming language version 1.2 book - Part 4 of 84
Mahmoud Samir Fayed
 
Golang
GolangGolang
Golang
GolangGolang
Continuous Delivery for Python Developers – PyCon Otto
Continuous Delivery for Python Developers – PyCon OttoContinuous Delivery for Python Developers – PyCon Otto
Continuous Delivery for Python Developers – PyCon Otto
Peter Bittner
 
Insight into progam execution ppt
Insight into progam execution pptInsight into progam execution ppt
Insight into progam execution ppt
Keerty Smile
 

Similar to Python debuggers slides (20)

Autotools, Design Patterns and more
Autotools, Design Patterns and moreAutotools, Design Patterns and more
Autotools, Design Patterns and more
 
Ice breaker with dev ops
Ice breaker with dev opsIce breaker with dev ops
Ice breaker with dev ops
 
icebreakerwithdevops-150218112943-conversion-gate02
icebreakerwithdevops-150218112943-conversion-gate02icebreakerwithdevops-150218112943-conversion-gate02
icebreakerwithdevops-150218112943-conversion-gate02
 
Programming tools for developers
Programming tools for developersProgramming tools for developers
Programming tools for developers
 
Using Delphi as a no code development environment
Using Delphi as a no code development environmentUsing Delphi as a no code development environment
Using Delphi as a no code development environment
 
Github developing stack
Github developing stackGithub developing stack
Github developing stack
 
The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189
 
Introduction of Tools for providing rich user experience in debugger
Introduction of Tools for providing rich user experience in debuggerIntroduction of Tools for providing rich user experience in debugger
Introduction of Tools for providing rich user experience in debugger
 
Introducing Yeoman 1.0 beta
Introducing Yeoman 1.0 betaIntroducing Yeoman 1.0 beta
Introducing Yeoman 1.0 beta
 
Frameworkless CLI app in PHP
Frameworkless CLI app in PHPFrameworkless CLI app in PHP
Frameworkless CLI app in PHP
 
What is dev ops?
What is dev ops?What is dev ops?
What is dev ops?
 
IDE and Toolset For Magento Development
IDE and Toolset For Magento DevelopmentIDE and Toolset For Magento Development
IDE and Toolset For Magento Development
 
Indy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-muleIndy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-mule
 
DevOps Workshop Part 1
DevOps Workshop Part 1DevOps Workshop Part 1
DevOps Workshop Part 1
 
The Ring programming language version 1.2 book - Part 4 of 84
The Ring programming language version 1.2 book - Part 4 of 84The Ring programming language version 1.2 book - Part 4 of 84
The Ring programming language version 1.2 book - Part 4 of 84
 
Golang
GolangGolang
Golang
 
Golang
GolangGolang
Golang
 
Continuous Delivery for Python Developers – PyCon Otto
Continuous Delivery for Python Developers – PyCon OttoContinuous Delivery for Python Developers – PyCon Otto
Continuous Delivery for Python Developers – PyCon Otto
 
Insight into progam execution ppt
Insight into progam execution pptInsight into progam execution ppt
Insight into progam execution ppt
 
DDD with Behat
DDD with BehatDDD with Behat
DDD with Behat
 

Recently uploaded

Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 

Recently uploaded (20)

Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 

Python debuggers slides

  • 2. About these slides These slides roughly correspond to a talk I gave at a DC Python meetup on 2014-04-01. During the actual talks I live-coded rather than referring to slides, but wanted to make a reference document for those that couldn’t make it.
  • 3. What’s a debugger? Like a DVR for your program: ● pause at any time ● step through line by line ● inspect values ● execute code
  • 4. Why do you need a debugger? Debuggers are a powerful tool to help you understand what your program is doing. They are invaluable in tracking bugs, understanding foreign code, and much more.
  • 5. Print statements are not good enough ● You end up re-running your code countless times inserting statements on random lines ● The output is unstructured and barely intelligible ● Your codebase becomes littered with accidentally committed debug statements
  • 6. Debugging is easy! Insert a breakpoint: pdb.set_trace() Start debugger after an exception: pdb.pm() #post-mortem
  • 7. PDB Commands h(elp) - list commands or get help on a command b(reak) - insert a breakpoint c(ontinue) - keep running until you hit a breakpoint s(tep) - continue until the next line executed (step into a function) n(ext) - continue until the next line in the current function r(eturn) - continue until the current function returns For a full list of commands (with better explanaitons), use the help command or consult the documentation
  • 8. Upgrade to ipdb! install: sudo pip install ipdb usage: s/pdb/ipdb/ … and that’s it! It works very similar, but with a few improvements: ● better context for traces ● colors ● more commands ● tab completion
  • 9. Upgrade to wdb! install: sudo pip install wdb usage: s/pdb/wdb/ have to run the server in the background: wdb.server.py & ● Launches a browser window ○ great for situations where you don’t have access to the terminal (like web servers) but can be used for any program ● awesome interface (easily jump around the call stack) ● better tab completion ● can access from other machines
  • 10. Making your own debugger Extend bdb.Bdb and override the user_* functions You can do whatever you want on function call/return, exception, and line executed: * write a profiler * visualize your code execution * make your ide smart about code usage: what functions actually call this one when we run our code? How often is this line executed?
  • 11. My pet project I’ve been writing a program that logs every line, function call, return, and exception to a file with timestamps and other important metadata. That part is working as a proof of concept (not terribly efficient) I hope to write multiple programs that can read that output and help developers better understand what their code is doing (what calls what, how long do things take, visualize code coverage, step through programs after they’ve finished running. I hope to post an initial version of this to github very soon. If you’re interested and want to talk, get updates, or help, please ping me on github/mattboehm or boehm.matthew@gmail.com
  • 12. Thanks! About me: https://github.com/mattboehm @mattboehm Founder of the DC/NoVA Vim Meetup: http://bit.ly/dcvim (I hope you can make it out to an event-- you’ll learn a lot no matter what your experience level) Python/JS developer at Novetta Solutions (I love my job-- talk to me if you’re looking for something new) Talk to me any time about: Vim, Python, AngularJS, Git, Linux, dvorak, mechanical/ergonomic keyboards, standing desks, meetups, podcasts, board games, or anything else that strikes your fancy