debugging in python · debugging tools pdb :: python debugger pdb++ :: pdb + new features:: tab...

23
Debugging In Python Jessica Mong

Upload: others

Post on 23-Jun-2020

35 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

Debugging In Python

Jessica Mong

Page 2: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

Outline

● Introduction● Devil’s Guide to Debugging (Debugging Software Udacity)

● Debugging tools ● pdb● Exercises and prizes● Q&A

Page 3: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

Outline

● Introduction● Devil’s Guide to Debugging● Debugging tools● pdb● Exercises and prizes● Q&A

Page 4: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

Introduction

● whoami

● Did you know?○ 50% - 75% of the time producing software is spent

on debugging and testing

Page 5: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

Outline

● Introduction● Devil’s Guide to Debugging● Debugging tools● pdb● Exercises and prizes● Q&A

Page 6: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

The Devil’s Guide to DebuggingThe DON’Ts

● Scatter output statements everywhere

● Debug the program into existence

● Never back up earlier versions

● Don’t understand what the program does

● Use the most obvious fix

Page 7: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

The Devil’s Guide to Debugging

● Scatter output statements everywhere

● Debug the program into existence

● Never back up earlier versions

● Don’t understand what the program does

● Use the most obvious fix

Page 8: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

The Devil’s Guide to Debugging

● Scatter output statements everywhere

● Debug the program into existence

● Never back up earlier versions

● Don’t understand what the program does

● Use the most obvious fix

Page 9: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

The Devil’s Guide to Debugging

● Scatter output statements everywhere

● Debug the program into existence

● Never back up earlier versions

● Don’t understand what the program does

● Use the most obvious fix

Page 10: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

The Devil’s Guide to Debugging

● Scatter output statements everywhere

● Debug the program into existence

● Never back up earlier versions

● Don’t understand what the program does

● Use the most obvious fix

Page 11: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

Outline

● Introduction● Devil’s Guide to Debugging● Debugging tools ● pdb● Exercises and prizes● Q&A

Page 12: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

Debugging Tools

pdb :: python debugger

pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode

ipdb :: pdb + Ipython capabilities

pudb :: “full-screen, console based visual debugger”

PyCharm IDEPython Breakpoints (Sublime Plugin)

Page 13: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

Debugging Tools

pdb :: python debugger

pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode

ipdb :: pdb + Ipython capabilities

pudb :: “full-screen, console based visual debugger”

PyCharm IDEPython Breakpoints (Sublime Plugin)

Page 14: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

Debugging Tools

pdb :: python debugger

pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode

ipdb :: pdb + Ipython capabilities

pudb :: “full-screen, console based visual debugger”

PyCharm IDEPython Breakpoints (Sublime Plugin)

Page 15: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

Debugging Tools

pdb :: python debugger

pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode

ipdb :: pdb + Ipython capabilities

pudb :: “full-screen, console based visual debugger”

PyCharm IDEPython Breakpoints (Sublime Plugin)

Page 16: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

Debugging Tools - http://svy.mk/1PU361w

pdb :: python debugger

pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode

ipdb :: pdb + Ipython capabilities

pudb :: “full-screen, console based visual debugger”

PyCharm IDEPython Breakpoints (Sublime Plugin)

Page 17: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

Outline

● Introduction● Devil’s Guide to Debugging● Debugging tools● pdb :: http://bit.ly/hackbright-debug● Exercises and prizes● Q&A

Page 18: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

pdb

import pdb; pdb.set_trace()

python -m pdb script.py

Page 19: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

pdb

l - listn - next (step over)

p - printpp - pretty printc - continuer - return

s - step (in)

b - breakpointscl - clear (breakpoints)

unt - untilq - quit

Page 20: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

Outline

● Introduction● Devil’s Guide to Debugging● Debugging tools ● pdb● Exercises and prizes● Q&A

Page 21: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

Outline

● Introduction● Devil’s Guide to Debugging● Debugging tools ● pdb● Exercises and prizes● Q&A

Page 22: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

Resources + Referencespdb Documentation

● Python Documentation● https://docs.python.org/2/library/pdb.html

Software Debugging● Adreas Zeller & Gundega Dekena● https://www.udacity.com/course/software-debugging--cs259

So You Think You can PDB● Clayton Parker● https://www.youtube.com/watch?v=j4Z8drp9jaA

Page 23: Debugging In Python · Debugging Tools pdb :: python debugger pdb++ :: pdb + new features:: tab completion, syntax highlighting, sticky mode ipdb :: pdb + Ipython capabilities pudb

Resources + ReferencesDebugging Exercises

● University of Sydney - Debugging Exercises● http://sydney.edu.

au/engineering/it/~jchan3/soft1001/jme/debugging/debugging_task.html