Is there a function in Python to list the attributes and methods of a particular object?
Something like:
ShowAttributes ( myObject ) -> .count -> .size ShowMethods ( myObject ) -> len -> parse
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You want to look at the
dir()function:Edit in response to comment:
No this will show all inherited methods as well. Consider this example:
test.py:
Python interpreter:
You should note that Python’s documentation states:
Therefore it’s not safe to use in your code. Use
vars()instead.Vars()doesn’t include information about the superclasses, you’d have to collect them yourself.If you’re using
dir()to find information in an interactive interpreter, consider the use ofhelp().