Skip to content

Instantly share code, notes, and snippets.

@biojerm
Last active February 28, 2020 04:55
Show Gist options
  • Select an option

  • Save biojerm/6257e973f6acbd46a3b4f17c8966667b to your computer and use it in GitHub Desktop.

Select an option

Save biojerm/6257e973f6acbd46a3b4f17c8966667b to your computer and use it in GitHub Desktop.
Demo for python pdb
def printer(value):
print(value.upper())
def looper():
vals = ['hello', 'world', 'and', 'ldp']
for val in vals:
printer(val)
def problem_child():
raise NotImplementedError
if __name__ == '__main__':
looper()
variable = 7 # here to show scope
problem_child()

How to start pdb

  • python -m pdb pdb_demo.py
  • python -m pytest --pdb
  • import pdb; pdb.set_trace()
  • breakpoint()

Demo

  • help
  • next
  • continue
  • breakpoint
  • up
  • down
  • jump
  • conditions

python shell

  • run python commands
  • jump to python shell with local vars
from demo import *
def tests_printer():
val = 'hello'
result = printer(val)
assert result == 'Hello'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment