Reputation: 170658
I try to list all the attributes of an object in Python pdb.
Let's say I want to list all the attributes and all methods of sys.stderr
.
How can I do that?
Upvotes: 49
Views: 61321
Reputation: 1200
print dir(object_name)
will list all the attributes of object for you.
Upvotes: 7
Reputation: 8968
pdb is like a python shell, what you can do in pdb is what you can do in Python (except maybe some very exotic stuff)
You can set variables, call functions, ...
dir
is the right function to call. It should work on any objects as it can either default to the builtin or be implemented but I have indeed seen objects on which it fails. I guess it has to do with "old" python code (in my failing case : the suds
library)
Usually __dict__
can be of some help too on the pdb debugger
Upvotes: 4
Reputation: 12950
If a is your object, use dir(a)
to get a list of its symbols. See the documentation about the dir
function for more information.
Upvotes: 10