Fix Python – Get all object attributes in Python? [duplicate]

Question

Asked By – user541686

Is there a way to get all attributes/methods/fields/etc. of an object in Python?

vars() is close to what I want, but it doesn’t work unless an object has a __dict__, which isn’t always true (e.g. it’s not true for a list, a dict, etc.).

Now we will see solution for issue: Get all object attributes in Python? [duplicate]


Answer

Use the built-in function dir().

This question is answered By – mouad

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0