Skip to content

Latest commit

 

History

History
32 lines (31 loc) · 1.09 KB

File metadata and controls

32 lines (31 loc) · 1.09 KB

pdb_the_python_debugger

a short notes of pdb, it will be useful when you are implementing your model with an unfriendly framework such as Mxnet.

log_in.py

class User():
  def __init__(self, name):
      self.name = name
      self.password = 'hello world'
  def log_in(self, password):
      if password == self.password:
          print('login success')
      else:
          print('your password is not correct')

  if __name__ == '__main__':
    user = User('Mike')
    user.log_in('abcd')
    user.log_in('hello world')

Command

l, list line
l n, list from line n
b n, set breaking point at line n
c, execute
n, execute next line
p variable, print variables
s, step in function
q, quit debugging mode

Run pdb

python -m pdb log_in.py

Results

Alt text Alt text Alt text