dot notation

In Python, the dot notation is a syntax that allows you to access attributes and methods of objects. It provides a way to drill down into an object to retrieve or modify its attributes or to call its methods.

When you use dot notation, you specify the object, followed by a dot (.), and then the name of the attribute or method you want to access. This powerful feature makes Python code intuitive and readable.

Example

Here’s an example of using the dot notation to access attributes and methods in a Python class:

Python cars.py
class Car:
    def __init__(self, color, model):
        self.color = color
        self.model = model

    def start(self):
        print("Car is started!")

# Usage
car = Car("red", "Toyota")
print(car.color)  # Output: red
print(car.model)  # Output: Toyota
print(car.start())  # Output: Car is started!

In this example, car.color and car.model use dot notation to access the attributes of the car object. Similarly, car.start() uses dot notation to call a method on the object.

Tutorial

Python Classes: The Power of Object-Oriented Programming

In this tutorial, you'll learn how to create and use full-featured classes in your Python code. Classes provide a great way to solve complex programming problems by approaching them through models that represent real-world objects.

intermediate python

For additional information on related topics, take a look at the following resources:


By Leodanis Pozo Ramos • Updated April 14, 2025 • Reviewed by Leodanis Pozo Ramos