List/inspect the instance variables (self.xxx) while using pudb

674 views Asked by At

I am trying to debug a python application using pudb, everything is fine and good except that it's not displaying the instance variables (which we access with self.xxx). It just displays 1 variable called self. And it's of the original class type.

Screenshot

Even if I tell it to show after calling str(self), it still only displays the object information.

Screenshot2

If you see the code has created many variables like self.parser, self.groups and I am not able to view/inspect any of them.

Is there a way to view all the instance variables of the current class while debugging using pudb?

2

There are 2 answers

1
Daniel Roseman On

This is the expected behaviour, and has nothing to do with your debugger: you only have one name, self.

To see its contents you can use dir(self).

0
absolutelyNoWarranty On

See inspect complex variable in python debugger, like pudb

The short way: Highlight the variable and press backslash \ to toggle between the "Expanded" view of a variable in the variable inspection panel.

In this case we would just highlight self, and press \, which is just the Python variable representing the instance of the class.

Alternatively, press ENTER to open the "Variable Inspection Options" menu where at the bottom you can see the "Expanded" option.