Check complex variable in python debugger like pudb

How can I check the value of a variable of a variable (list, dict, object) using the python debugger, I am new to python, I tried pudb, it seems when the variable type is a complex type, the debugger shows the variable type, not the value.

Is it possible to check the value with pudb? or can another python debugger do this?

+4
source share
3 answers

To view the contents of a complex data type in pudb:

  • Use the right arrow to move the cursor to the Variables field on the right.

  • Use the up and down arrows to move the cursor to the variable of interest.

  • Use the backslash '\' to show / hide the contents of the data structure.

+5
source

The print statement for a sequence type works enough in the pdb console tray, as shown below.

>>> import pdb >>> l=[9,0] >>> def j():l=[1,2,3] ... >>> pdb.run('j()') > <string>(1)<module>() (Pdb) continue >>> pdb.run('j()') > <string>(1)<module>() (Pdb) print l [1, 2, 3] 

Some print obj.name statements will also work to access the attribute of an object.

+1
source

You can simply go to the python / ipython shell by pressing "!"., Then you can play with your variables (view them, change them, etc.).

+1
source

Source: https://habr.com/ru/post/1434208/


All Articles