After trying Lavi Kumar's example it seems the package import pdbext.debug in ~/.pdbrc goes out of scope when another source file is called.
~/.pdbrc:
!import pdbext.debug
alias pl !pdbext.debug.debug_print(locals())
in /usr/local/lib/python3.4/site-packages/pdbext/debug.py:
def debug_print(d):
print("debug_print() d =", d, flush=True)
return
test.py:
import test2
def test1():
i = 0
print("test1()", flush=True)
test2.test3()
return
test1()
test2.py:
def test3():
a = 4
print("test3()", flush=True)
return
pdb session:
python3 -m pdb test.py
(Pdb) b 6
(Pdb) continue
(Pdb) pl
shows: debug_print() d = {'i': 0}
(Pdb) step
(Pdb) step (this puts pdb in test2.test3())
(Pdb) pl
shows: *** NameError: name 'pdbext' is not defined
Can someone please explain how to keep import pdbext.debug always in scope?