Monday, September 18, 2017

Python debug

The debug of Python script is not difficult. Just add this line:
import pdb; pdb.set_trace()
in the Python script.

For example:
import sys

def log(args):
    print(args)

def main(args):
    log(args)

import pdb;pdb.set_trace()
main(sys.argv)

The execution will be stopped at the line:




Commandes of the python debugDetail
sStep in.
nNext. Step over.
rReturn. Step out.
lList. This shows the code around the current location.
aArgs.
pPrint. Use this way: p some_variable
cContinue.