Class Attribute

say it: “klas AT-ruh-byoot” /klæs ˈætrəˌbjut/

Data shared by every object made from a class.

What is a class attribute?

A class attribute is shared by every object made from the class, instead of each object having its own.

class Employee:
    company = "Acme Co"          # shared by everyone

    def __init__(self, name):
        self.name = name         # each person's own

print(Employee("Ana").company)  # Acme Co

Level: Journeyman · More Python terms at this level

Updated

In other subjects