[FIXED] How do I enter Python code in PDB without having it interpreted as a command?

Issue

Sometimes I want to type Python code in PDB, if that code happens to start with a PDB command, you'll get an error

(Pdb) list()
*** Error in argument: '()'

How do I avoid this? It's sometimes surprising because I haven't memorized all 40-ish commands and their short forms and my code will just error.


Solution

You prefix them with !:

(Pdb) !list()
[]

https://docs.python.org/3/library/pdb.html#pdbcommand-!



Answered By - Boris Verkhovskiy
Answer Checked By - Robin (Python.Easybugfix Admin)

Related Posts

Post a Comment