Use PDB to check variables before crashes

1. Use `python -i your_script.py` to execute your program with interactive mode. This means, after your program finishes executing, or your program crashes in the midway, you will enter a python shell.

2. Suppose your script has a bug so that you enter the python shell after it crashes. Now you can play with pdb by:

import pdb
pdb.pm()
# print your variables or do whatever you want

 

Leave a comment

Your email address will not be published. Required fields are marked *