Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (45.3k points)

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.).

1 Answer

0 votes
by (16.8k points)

You can do it by using the built-in function dir().

Related questions

0 votes
1 answer
0 votes
1 answer
asked Feb 24, 2021 in Python by laddulakshana (16.4k points)
0 votes
1 answer
0 votes
1 answer
asked Jan 2, 2021 in Python by ashely (50.2k points)

Browse Categories

...