Python: Debugging pdb, Ipython Magics
Python Debugging
pdb is a standard python debuger and to invoke it we can call brakpoint() in scripts or use %pdb magic in iPython. Documentation
In pdb pythons standard debugger, help command directs you further. Some shortcuts are n next line, s step into, c for continue. You can do anything w.r.t ipython shell.
More info: https://realpython.com/python-debugging-pdb/
Some of other tools/ways are:
from IPython import embed; embed()from import ipdb; ipdb.set_trace()
IPython trics:
All and more about useful ipython %magic and debugging can be found here:
Great reference: https://jakevdp.github.io/PythonDataScienceHandbook/index.html
%lsmagicto list all available magic commands%<magic>?: to understand the magic command more- Debugging:
%debugwill bringpdbfrom when exception was raised and hence you can check all variables%xmode Plain,%xmode Verbose%pdb on,%pdb off,%pdb 1,%pdb 0- To bring up 
pdbwhenever exception is raised set%pdb on. 
 - Profiling:
%time: Time the execution of a single statement%timeit: Time repeated execution of a single statement for more accuracy%prun: Run code with the profiler%lprun: Run code with the line-by-line profiler%memit: Measure the memory use of a single statement%mprun: Run code with the line-by-line memory profiler
 - Listing variables:
dir()globals()locals()