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
🌐
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....
Discussions

introspection - Get all object attributes in Python? - Stack Overflow
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. ... More on stackoverflow.com
🌐 stackoverflow.com
python - Is there a way to access the formal parameters if you implement __getattribute__ - Stack Overflow
It seems as though __getattribute__ has only 2 parameters (self, name). However, in the actual code, the method I am intercepting actually takes arguments. Is there anyway to access those argumen... More on stackoverflow.com
🌐 stackoverflow.com
How can you set class attributes from variable arguments (kwargs) in python - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Suppose I have a class with a constructor (or other function) that takes a variable number of arguments and then sets them as class attributes conditionally. I could set them manually, but it seems that variable parameters are common enough in python ... More on stackoverflow.com
🌐 stackoverflow.com
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
People also ask

What is a Python namespace?

A Python namespace is a mapping from names to objects, with the property that there is zero relation between names in different namespaces. Namespaces are usually implemented as Python dictionaries, although this is abstracted away.

🌐
toptal.com
toptal.com › python › python-class-attributes-an-overly-thorough-guide
Python Class Attributes: An Overly Thorough Guide | Toptal®
What happens if both instance attribute and class attribute are defined?

In that case, the instance namespace takes precedence over the class namespace. If there is an attribute with the same name in both, the instance namespace will be checked first and its value returned.

🌐
toptal.com
toptal.com › python › python-class-attributes-an-overly-thorough-guide
Python Class Attributes: An Overly Thorough Guide | Toptal®
Python class method versus instance method: What’s the difference?

In Python, a class method is a method that is invoked with the class as the context. This is often called a static method in other programming languages. An instance method, on the other hand, is invoked with an instance as the context.

🌐
toptal.com
toptal.com › python › python-class-attributes-an-overly-thorough-guide
Python Class Attributes: An Overly Thorough Guide | Toptal®
Top answer
1 of 2
2

This link here can explain more about class attributes/methods/parameters.

However, I do understand how complicated these concepts are, so I will answer your question (although in the future, try to ask a more specific question!).

In example one:

init (the initializer) and print_time are both class attributes. When you initialize the clock variable and pass in the parameter '5:30', it accesses the init function and hits the self.time = time line of code. Since time is accessed using a dot notation, time is an INSTANCE attribute (specific to the individual object).

When you call self.print_time(), the time there is a local variable specific to the function call, therefore the instance attribute is not changed. That is why when you print self.time it is still 5:30.

In example two:

In this case, the init and print_time functions are both class attributes (similar to the example above). The initialization of the clock object is the same as above. However, when it calls print_time, time is a the parameter '10:30', and therefore when we just print time (notice we did not use any dot notation), it prints only the local variable of '10:30'.

In example three:

init and print_time are both class attributes, same as the above two examples. When you initialize the boston_clock object, it is similar to both example one and two. Then you assign the name paris_clock to the object boston_block (notice that paris_clock and boston_clock are just names pointing to the same object, like how I could have two names). Therefore when we execute the line of code paris_clock.time = '10:30', the INSTANCE attribute of this single object is changed to '10:30'. However, since boston_clock is pointing to the same object as paris_clock, boston_clock's time attribute is also '10:30'.

2 of 2
2

Attributes are the variables within a class or instance. In something like this the variable hello is an attribute of the class Hi.

class Hi:
  hello = "Hello World!"

Methods are functions within the class, so for something like this, function greet is a method of the class Hi.

class Hi:
  def greet(self):
    pass

Parameters are input(s) that go into a method. So the string, "Hello World!" is a parameter of the method say in the class Hi.

class Hi:
  def say(self, saying):
    print(saying)

Hi().say("Hello World!")

There's a nice question on the Software Engineering StackExchange site about OOPL. Explaining OOP Concepts to a non technical person.

🌐
Enterprise DNA
blog.enterprisedna.co › python-get-all-attributes
Python: Get All Attributes Explained With Examples – Master Data Skills + AI
If we don’t specify an object, the dir() function will return all the attributes and methods in the local namespace. For example: ... The getattr() function allows you to retrieve the value of attributes from an object. You can retrieve this value by providing the object and the attribute ...
Find elsewhere
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-getattr
Python getattr() | DigitalOcean
August 3, 2022 - 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. Basically, returning the default value is the main reason why you may need to use Python getattr() function.
🌐
Toptal
toptal.com › python › python-class-attributes-an-overly-thorough-guide
Python Class Attributes: An Overly Thorough Guide | Toptal®
January 16, 2026 - This Python guide outlines specific use cases for attributes, properties, variables, objects, and more.
🌐
GeeksforGeeks
geeksforgeeks.org › python-getattr-method
Python | getattr() method - GeeksforGeeks
November 25, 2024 - Then we created an object of the class and we are getting the attribute name-value with getattr(). ... In this example, we have defined a class name GFG and there are two class variables named, the age we call the gender attribute which is not present in the class, which is showing the output AttributeError. ... # Python code to demonstrate # working of getattr() # declaring class class GfG: name = "GeeksforGeeks" age = 24 # initializing object obj = GfG() # use of getattr without default print("Gender is " + getattr(obj, 'gender'))
🌐
Python
docs.python.org › 3 › library › inspect.html
inspect — Inspect live objects
Changed in version 3.14: Add f_generator attribute to frames. ... Return all the members of an object in a list of (name, value) pairs sorted by name. If the optional predicate argument—which will be called with the value object of each member—is supplied, only members for which the predicate returns a true value are included. ... getmembers() will only return class attributes defined in the metaclass when the argument is a class and those attributes have been listed in the metaclass’ custom __dir__().
🌐
Programiz
programiz.com › python-programming › methods › built-in › getattr
Python getattr()
Created with over a decade of experience. ... Created with over a decade of experience and thousands of feedback. ... Try Programiz PRO! ... Become a certified Python programmer. Try Programiz PRO! ... The getattr() method returns the value of the named attribute of an object.
🌐
FavTutor
favtutor.com › blogs › print-object-attributes-python
How to Print Object Attributes in Python? (with Code)
October 14, 2022 - Example: To print the attributes of objects in Python by using the dir() function with an object as an argument.
🌐
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
· Author has 718 answers and 266K answer views · 3y · For the complete list of attributes, the short answer is: no. The problem is that the attributes are actually defined as the arguments accepted by the getattr built-in function.
🌐
Medium
medium.com › @tzuni_eh › use-getattr-to-get-attributes-methods-dynamically-124d344c0c3d
Use getattr() to get method dynamically in Python | by Eva(Tzuni) Hsieh | Medium
January 26, 2019 - What I am doing in here is using getattr() function to get modules from arguments_handlersdynamically instead of doing so many copy-and-paste. mod = myobject.first_name · equals to · mod = getattr(myobject 'first_name') # the attribute name ...
🌐
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?

🌐
Python documentation
docs.python.org › 3 › reference › datamodel.html
3. Data model — Python 3.14.3 documentation
In order to avoid infinite recursion ... name to access any attributes it needs, for example, object.__getattribute__(self, name). ... This method may still be bypassed when looking up special methods as the result of implicit invocation via language syntax or built-in functions. See Special method lookup. For certain sensitive attribute accesses, raises an auditing event object.__getattr__ with arguments obj and ...
🌐
GeeksforGeeks
geeksforgeeks.org › 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.
🌐
Iditect
iditect.com › faq › python › how-to-set-class-attributes-from-variable-arguments-kwargs-in-python.html
How to set class attributes from variable arguments (kwargs) in python
You can set class attributes from variable keyword arguments (kwargs) in Python by iterating through the kwargs dictionary and using setattr() to assign the values to the class attributes.
🌐
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 - MyClass uses __slots__ to limit attributes to x and y, saving memory by removing __dict__. Creating m with values 10 and 20 lets you access these attributes and MyClass.__slots__ lists them.