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?
If you're only interested in debugging a Python script, the simplest way is to select the down-arrow next to the run button on the editor and select Debug Python File in Terminal.
Directly use command python pdg-debug.py without -m pdb to run the code. The program will automatically break at the position of pdb. set_trace() and enter the pdb debugging environment. You can use the command p variable to view the variables or use the command c to continue to run.
Python has a built-in debugger called pdb . It's a simple utility with a command line interface that does the main job. It has all the debugger features you'll need, but if you're looking to pimp it up a little, you can extend it using ipdb, which will provide the debugger with features from IPython.
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]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With