Attribute

noun

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

A piece of data that belongs to an object, reached with a dot, such as novel.pages.

What is an attribute?

An attribute is a piece of data that belongs to an object, reached with a dot.

class Book:
    def __init__(self, title, pages):
        self.title = title
        self.pages = pages

novel = Book("Dune", 412)
print(novel.pages)  # 412

In a sentence

  • “Each book object has a title attribute and a pages attribute.”
  • “account.balance reads the balance attribute of one account.”

Level: Journeyman · More Python terms at this level

Updated

In other subjects