Try the inspect module. getmembers and the various tests should be helpful.

EDIT:

For example,

class MyClass(object):
    a = '12'
    b = '34'
    def myfunc(self):
        return self.a

>>> import inspect
>>> inspect.getmembers(MyClass, lambda a:not(inspect.isroutine(a)))
[('__class__', type),
 ('__dict__',
  <dictproxy {'__dict__': <attribute '__dict__' of 'MyClass' objects>,
   '__doc__': None,
   '__module__': '__main__',
   '__weakref__': <attribute '__weakref__' of 'MyClass' objects>,
   'a': '34',
   'b': '12',
   'myfunc': <function __main__.myfunc>}>),
 ('__doc__', None),
 ('__module__', '__main__'),
 ('__weakref__', <attribute '__weakref__' of 'MyClass' objects>),
 ('a', '34'),
 ('b', '12')]

Now, the special methods and attributes get on my nerves- those can be dealt with in a number of ways, the easiest of which is just to filter based on name.

>>> attributes = inspect.getmembers(MyClass, lambda a:not(inspect.isroutine(a)))
>>> [a for a in attributes if not(a[0].startswith('__') and a[0].endswith('__'))]
[('a', '34'), ('b', '12')]

...and the more complicated of which can include special attribute name checks or even metaclasses ;)

Answer from Matt Luongo on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-get-a-list-of-class-attributes-in-python
How to Get a List of Class Attributes in Python? - GeeksforGeeks
July 12, 2025 - Creating m with values 10 and 20 lets you access these attributes and MyClass.__slots__ lists them. Another way of finding a list of attributes is by using the module inspect. This module provides a method called getmembers() that returns a ...
Discussions

Any way to get ALL attributes of an object in python?
movieobject.__dict__ will give you al the attributes and their values movieobject.__dict__.keys() will give you only the names of the attributes. More on reddit.com
๐ŸŒ r/learnpython
10
9
June 20, 2024
python - List attributes of an object - Stack Overflow
I want this to see the current attributes from various parts of a script. ... Virtually everyone in Python names their classes like NewClass. You may defy people's expectations if you use a naming convention like new_class. ... Even though it is human-interactive and cannot be programatically used, help() function helps for getting ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Accessing attributes of a class
How do I access the attributes of a class, such as, __bases__, __name__, __qualname__? When I do this, class C: pass dir(C) then it gives me, ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', ... More on discuss.python.org
๐ŸŒ discuss.python.org
0
0
February 22, 2022
Python: How to get attribute of attribute of an object with getattr? - Stack Overflow
Stack Internal Implement a knowledge platform layer to power your enterprise and AI tools. Stack Data Licensing Get access to top-class technical expertise with trusted & attributed content. More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ bytes โ€บ get-all-object-attributes-in-python
Get All Object Attributes in Python
August 24, 2023 - Whether you're using dir(), the __dict__ attribute, overriding the str function, or using the vars() function, Python provides a variety of tools to extract and manipulate object attributes. ... Reliable monitoring for your app, databases, infrastructure, and the vendors they rely on.
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ python-getattr
Python getattr() | DigitalOcean
August 3, 2022 - In our previous tutorial we learned about python system command. In this tutorial we will be discussing about Python getattr() function. Python getattr() function is used to get the value of an objectโ€™s attribute and if no attribute of that object is found, default value is returned.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ any way to get all attributes of an object in python?
r/learnpython on Reddit: Any way to get ALL attributes of an object in python?
June 20, 2024 -

I'm using the plex python library to get some info from my plex server.

What I wanted to get was the path of a movie.

I tried to use dir(movie_object), vars(movie_object), and movie_object.__dict__ to try and find all of the movie attributes, and to see where the path was stored.

But there was no attribute that contained the file path information.

In the end I found it under movie_object.location by inspecting the object in the VSCode debugging tools.

Why does VSCode show the location attribute, but dir, vars, or __dict__ do not show it?

Is there a way to reliably get ALL of an objects attributes in python?

๐ŸŒ
Quora
quora.com โ€บ How-do-I-get-a-complete-list-of-objects-methods-and-attributes-in-Python
How to get a complete list of object's methods and attributes in Python - Quora
Summary: start with inspect.getmembers(obj) for a comprehensive runtime list, use dir() for names-only quick view, inspect and MRO traversal to classify and find the origin, and fallback to trying getattr or reading source when attributes are produced dynamically or by C-extensions. ... RelatedWhat are classes, objects, instances, methods, and attributes in Python?
Find elsewhere
๐ŸŒ
Enterprise DNA
blog.enterprisedna.co โ€บ python-get-all-attributes
Python: Get All Attributes Explained With Examples โ€“ Master Data Skills + AI
One common task in application development is working with objects and their attributes. To get all attributes in Python, there are built-in functions, such as dir(), var(), and getattr(), that enable developers to access and traverse object attributes with ease.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ accessing-attributes-methods-python
Accessing Attributes and Methods in Python - GeeksforGeeks
March 29, 2025 - Let's explore them one by one. Attributes can be accessed, modified or deleted dynamically using built-in functions. getattr(obj, attr, default): Retrieves an attribute's value; returns default if missing.
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ reference โ€บ datamodel.html
3. Data model โ€” Python 3.14.3 documentation
Regular attribute dot-notation is used to get and set such attributes. CPython implementation detail: CPythonโ€™s current implementation only supports function attributes on user-defined functions.
๐ŸŒ
Flexiple
flexiple.com โ€บ python โ€บ print-object-attributes-python
How to Print Object Attributes in Python? - Flexiple
March 22, 2024 - The inspect.getmembers(obj) function retrieves all the members of obj. The loop then filters out unique methods (those starting with __) and prints the name and value of each attribute.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_func_getattr.asp
Python getattr() Function
Python Examples Python Compiler ... age = 36 country = "Norway" x = getattr(Person, 'age') Try it Yourself ยป ยท The getattr() function returns the value of the specified attribute from the specified object....
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
Accessing attributes of a class - Python Help - Discussions on Python.org
February 22, 2022 - When I do this, class C: pass dir(C) then it gives me, ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-print-object-attributes-in-python
How to Print Object Attributes in Python - GeeksforGeeks
July 23, 2025 - This article will guide you through various methods to print object attributes in Python.
๐ŸŒ
Bobby Hadz
bobbyhadz.com โ€บ blog โ€บ python-get-attributes-of-object
Get all Attributes or Methods of an Object in Python | bobbyhadz
April 10, 2024 - Make sure to use inspect.isfunction ... Alternatively, you can use the dir() function. ... Use the dir() function to get a list of the names of the class's attributes....
๐ŸŒ
Python Central
pythoncentral.io โ€บ how-to-get-an-attribute-from-an-object-in-python
How to get an attribute from an object in Python - Python Central
December 29, 2021 - [python] >>> from collections import namedtuple >>> import os >>> Transformer = namedtuple('Transformer', ['transform_png', 'transform_txt']) >>> transformer = Transformer('transform .png files', 'transform .txt files') >>> # Suppose the current directory has two files 'tmp.png' and 'tmp.txt' >>> current_directory = os.path.dirname(os.path.abspath(__file__)) >>> for dirname, dirnames, filenames in os.walk(current_directory): ... for filename in filenames: ... path = os.path.join(dirname, filename) ... filename_prefix, ext = filename.rsplit('.', 1) ... if ext == 'png' or ext == 'txt': ... print(getattr(transformer, 'transform_{0}'.format(ext))) ... transform .png files transform .txt files [/python] Although getattr is quite handy when dealing with introspection and meta-programming, it does make the code harder to read.
๐ŸŒ
pythoncodelab
pythoncodelab.com โ€บ home โ€บ get attributes of object python
Get attributes of object Python - pythoncodelab
November 2, 2025 - If we want only the attributes which the user has defined and not the built-in ones then we can use the __dict__ attribute for that. ... This approach is perfect if we are trying to get all attributes and values of object Python without the extra noise.
๐ŸŒ
Thedigitalcatonline
thedigitalcatonline.com โ€บ blog โ€บ 2015 โ€บ 01 โ€บ 12 โ€บ accessing-attributes-in-python
The Digital Cat - Accessing attributes in Python
January 12, 2015 - This usually happens when writing debuggers or inspection tools that let the user interactively specify the attributes they want to see. To perform this "indirect" access Python provides the getattr() builtin function, which accepts an object and the name of an attribute.