Terminology

Mental model:

  • A variable stored in an instance or class is called an attribute.
  • A function stored in an instance or class is called a method.

According to Python's glossary:

attribute: A value associated with an object which is referenced by name using dotted expressions. For example, if an object o has an attribute a it would be referenced as o.a

method: A function which is defined inside a class body. If called as an attribute of an instance of that class, the method will get the instance object as its first argument (which is usually called self). See function and nested scope.

Examples

Terminology applied to actual code:

a = 10                          # variable

def f(b):                       # function  
    return b ** 2

class C:

    c = 20                      # class attribute

    def __init__(self, d):      # "dunder" method
        self.d = d              # instance attribute

    def show(self):             # method
        print(self.c, self.d) 

e = C(30)
e.g = 40                        # another instance attribute
Answer from Raymond Hettinger on Stack Overflow
🌐
Python documentation
docs.python.org › 3 › tutorial › classes.html
9. Classes — Python 3.14.3 documentation
Creating a new class creates a new type of object, allowing new instances of that type to be made. Each class instance can have attributes attached to it for maintaining its state. Class instances can also have methods (defined by its class) ...
🌐
Turing
turing.com › kb › introduction-to-python-class-attributes
A Guide to Python Class Attributes and Class Methods
They can be accessed using the class name and through an instance of the class. Class attributes are defined outside of any method, including the init method, and are typically assigned a value directly.
People also ask

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®
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®
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®
🌐
Alma Better
almabetter.com › bytes › tutorials › python › methods-and-attributes-in-python
Attributes and Methods in Python
February 29, 2024 - Attributes can be instances or class attributes, while methods can be instances, classes, or static methods. Using attributes and methods enables objects to 🤝 interact with each other, model real-world entities and scenarios, and make🖥️ software development more modular, reusable, and maintainable. Attributes in Python are variables associated with an object and are used to store data related to the object...
🌐
Real Python
realpython.com › python-classes
Python Classes: The Power of Object-Oriented Programming – Real Python
December 15, 2024 - In Python, attributes are variables defined inside a class with the purpose of storing all the required data for the class to work. Similarly, you’ll use the term methods to refer to the different behaviors that objects will show.
🌐
Toptal
toptal.com › python › python-class-attributes-an-overly-thorough-guide
Python Class Attributes: An Overly Thorough Guide | Toptal®
January 16, 2026 - 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.
🌐
Python Course
python-course.eu › oop › class-instance-attributes.php
2. Class vs. Instance Attributes | OOP | python-course.eu
March 22, 2024 - The call "x.RobotInstances()" is treated as an instance method call and an instance method needs a reference to the instance as the first parameter. So, what do we want? We want a method, which we can call via the class name or via the instance name without the necessity of passing a reference to an instance to it.
Find elsewhere
🌐
Medium
medium.com › @samersallam92 › 5-class-attributes-and-class-methods-in-python-oop-333dcfbb3578
Class Attributes and Class Methods in Python OOP | Medium
April 26, 2022 - Class attributes and class methods of classes and objects in Python oop. How to define class attributes and methods syntax and practical examples. Class method decorator.
🌐
Medium
gokulapriyan.medium.com › understanding-python-class-components-attributes-methods-and-properties-explained-1b83402098ed
🔍 Understanding Python Class Components: Attributes, Methods, and Properties Explained” | by Gokulapriyan | Medium
September 26, 2024 - Introduction: In Python, classes are made up of three key parts: attributes, methods, and properties. Attributes store data, methods define actions, and properties help control access to data.
🌐
Built In
builtin.com › software-engineering-perspectives › python-attributes
Python Attributes: Class vs. Instance | Built In
Python attributes are variables or methods associated with an object that store data about the object's properties and behavior. Class attributes belong to a class, while instance attributes belong to a specific object and are unique to each object.
🌐
Readthedocs
python-textbok.readthedocs.io › en › 1.0 › Classes.html
Classes — Object-Oriented Programming in Python 1 documentation
Classes and types are themselves objects, and they are of type type. You can find out the type of any object using the type function: ... The data values which we store inside an object are called attributes, and the functions which are associated with the object are called methods...
Top answer
1 of 4
4

Class attributes are same for all instances of class whereas instance attributes is particular for each instance. Instance attributes are for data specific for each instance and class attributes supposed to be used by all instances of the class.

"Instance methods" is a specific class attributes which accept instance of class as first attribute and suppose to manipulate with that instance.

"Class methods" is a methods defined within class which accept class as first attribute not instance(that's why the are class methods).

You can easily see class attributes by accessing A.__dict__:

class A:
   class_attribute = 10
   def class_method(self):
       self.instance_attribute = 'I am instance attribute'

print A.__dict__
#{'__module__': '__main__', 'class_method': <function class_method at 0x10978ab18>, 'class_attribute': 10, '__doc__': None}

And instance attributes as A().__dict__:

a = A()
a.class_method()
print a.__dict__
# {'instance_attribute': 'I am instance attribute'}

Some useful links from official python documentation and SO, which i hope won't confuse you more and give clearer understanding...

  • Python Classes
  • Dive into python, 5.8. Introducing Class Attributes
  • Definition of python getattr and setattr
  • What are Class methods in Python for?
  • Difference between Class and Instance methods
2 of 4
3

To answer this question, you need to first think about how python looks up attributes. I'll assume you know what an instance is. As a refresher. . .

class SomeClass(object):

    class_attribute = 'This -- Defined at the class level.'

    def __init__(self):
        self.instance_attribute = 'This -- Defined on an instance.'

    def method(self):
        pass

instance = SomeClass()

Class attributes are defined at the class level. Instance attributes are defined at the instance level (usually via self.xyz = ...). Instance attributes can also be monkey patched onto the instance:

instance.another_instance_attribute = '...'

Notice that class attributes can be looked up on an instance if an instance attribute doesn't "shadow" it.

print(instance.class_attribute)

Now for methods. Methods are another animal entirely.

SomeClass.method

is definitely an attribute on the class.

instance.method

is a bit trickier to classify. Actually, when python sees that statement, it actually executes the following:

SomeClass.method.__get__(instance, SomeClass)

Weird. So what is happening here is that functions are descriptors. Since they have a __get__ method, it gets called and the return value (in this case) is a new function that knows what self is. The normal terms are "instance method" and "bound method". I suppose some might consider it an instance attribute, but, I'm not sure that's exactly correct (even though you access it via the instance)

Top answer
1 of 1
10

Your friend was wrong. Methods are attributes.

Everything in Python is objects, really, with methods and functions and anything with a __call__() method being callable objects. They are all objects that respond to the () call expression syntax.

Attributes then, are objects found by attribute lookup on other objects. It doesn't matter to the attribute lookup mechanism that what is being looked up is a callable object or not.

You can observe this behaviour by looking up just the method, and not calling it:

>>> class Foo(object):
...     def bar(self):
...         pass
... 
>>> f = Foo()
>>> f.bar
<bound method Foo.bar of <__main__.Foo object at 0x1023f5590>>

Here f.bar is an attribute lookup expression, the result is a method object.

Of course, your friend me be a little bit right too; what is really happening is that methods are special objects that wrap functions, keeping references to the underlying instance and original function, and are created on the fly by accessing the function as an attribute. But that may be complicating matters a little when you first start out trying to understand Python objects. If you are interested in how all that works, read the Python Descriptor HOWTO to see how attributes with special methods are treated differently on certain types of attribute access.

This all works because Python is a dynamic language; no type declarations are required. As far as the language is concerned, it doesn't matter if Foo.bar is a string, a dictionary, a generator, or a method. This is in contrast to compiled languages, where data is very separate from methods, and each field on an instance needs to be pinned down to a specific type beforehand. Methods generally are not objects, thus a separate concept from data.

🌐
GeeksforGeeks
geeksforgeeks.org › class-instance-attributes-python
Class and Instance Attributes in Python - GeeksforGeeks
The method __new__ is the constructor that creates a new instance of the class while __init__ is the init ... In Python, when defining methods within a class, the first parameter is always self.
Published   September 5, 2024
🌐
LabEx
labex.io › tutorials › python-how-to-define-class-attributes-and-methods-at-runtime-398174
How to define class attributes and methods at runtime | LabEx
In Python, classes are the fundamental building blocks for creating objects. Each class has its own set of attributes (variables) and methods (functions) that define the behavior and properties of the objects created from that class.
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.

🌐
Real Python
realpython.com › lessons › class-and-instance-attributes
Class and Instance Attributes (Video) – Real Python
In the next video, we’ll start programming our Dog class and we’ll see how class instantiation works in Python. ... In the text below the video, don’t you need to change: “Behaviors are actually called Attributes.” to “Properties are actually called Attributes & Behaviors are actually called Methods...
Published   March 22, 2019
🌐
freeCodeCamp
freecodecamp.org › news › python-attributes-class-and-instance-attribute-examples
Python Attributes – Class and Instance Attribute Examples
April 12, 2022 - The school variable acts as a class attribute while name and course are instance attributes. Let's break the example above down to explain instance attributes. Student1 = Student("Jane", "JavaScript") Student2 = Student("John", "Python") print(Student1.name) # Jane print(Student2.name) # John
🌐
Python Tutorial
pythontutorial.net › home › python oop › python class attributes
Understanding Python Class Attributes By Practical Examples
November 13, 2020 - To define a class attribute, you place it outside of the __init__() method. Use class_name.class_attribute or object_name.class_attribute to access the value of the class_attribute. Use class attributes for storing class contants, track data across all instances, and setting default values ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › accessing-attributes-methods-python
Accessing Attributes and Methods in Python - GeeksforGeeks
March 29, 2025 - In Python, attributes and methods define an object's behavior and encapsulate data within a class. Attributes represent the properties or characteristics of an object, while methods define the actions or behaviors that an object can perform.