0

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?

2
  • This question is similar to: More parsing-friendly Python debugger locals() output. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Nov 11 at 22:46
  • 1
    This is actually a second question that came up after the first question was answered on previous post. I moved the 2nd question to this post Commented Nov 12 at 1:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.