How do I call the Python's list while debugging?
I have the following python code:
values = set([1, 2, 3, 4, 5])
import pdb
pdb.set_trace()
I run the script and I am in the debugging shell:
(pdb) list(values)
*** Error in argument: '(values)'
(Pdb)
How can I call list(values)
in the debugger without invoking the debugger's own list
command?
Just print
it:
(Pdb) print list(values)
don't foget to add brackets for python3 version
(Pdb) print(list(values))
Use the exclamation mark ! to escape debugger commands:
(Pdb) values = set([1, 2, 3, 4, 5])
(Pdb) list(values)
*** Error in argument: '(values)'
(Pdb) !list(values)
[1, 2, 3, 4, 5]
Thierry,
Since this data structure is already an sequence it is redundant to specify it as a list. So this will work fine.
(Pdb) print values
or
(Pbd) print(values)
if you are using Python3
Optionally for a nice listing with newlines
(Pdb) for x in values: print x
or
(Pdb) for x in values: print(x)
for Python3