I want to start a pdb session from the Python shell on a function using pdb.run()
.
I know that I can give it a globals
or a locals
parameter, but I don't know what values to pass so that I keep all of my current imports in the debugger session.
pdb.run('myfunction()')
doesn't seem to keep any previous imports I made in the shell.
Asked
Active
Viewed 61 times
0

Martijn Pieters
- 1,048,767
- 296
- 4,058
- 3,343

Mihai Oprea
- 2,051
- 3
- 21
- 39
1 Answers
1
I found the answer. You need to pass in the result of the locals()
function:
pdb.run('myfunction()',locals())

AndyG
- 39,700
- 8
- 109
- 143

Mihai Oprea
- 2,051
- 3
- 21
- 39