An attribute is a piece of data that belongs to an object. It describes a characteristic of that object: a circle might have a radius, while a rectangle might have a length and a width. Attributes are also called object properties or data attributes. They differ from behaviors, which are actions an object can perform. section 30.2 section 31.2
When you create a class, decide which attributes each object needs. Its `__init__` method usually gives them their starting values. Write `self.` before an attribute name to show that the value belongs to the object. Each object created from the class has its own values. section 31.2
A rectangle’s attributes
A `Rectangle` can start with `length` and `width`. In `__init__(self, length, width)`, the assignments `self.length = length` and `self.width = width` store the supplied values as attributes. For `Rectangle(2, 4)`, those values are 2 and 4. The parameters are temporary; the attributes remain with the rectangle after `__init__` finishes. Passing only one value produces an error because both are required. section 31.5
Listing 31.1. A Rectangle class
class Rectangle(object):
""" a rectangle object with a length and a width """
def __init__(self, length, width):
self.length = length
self.width = width
def set_length(self, length):
self.length = length
def set_width(self, width):
self.width = width
See the complete `Rectangle` class: `__init__` stores two attributes, and methods can change them. section 31.5
Dot notation lets you refer to an object’s property or call one of its methods. For example, `a_rectangle.length` refers to a rectangle’s length; `a_rectangle.set_length(3)` calls a method that changes it. The dot connects the name to that particular object. section 31.5 section 30.3
Choosing an attribute
A stack can keep its items in one list attribute, initialized with `self.stack = []`. Methods then add or remove items using that list. Quick check: if you made a circle class, which attribute would you choose to describe its size? A radius is one option. section 32.1 section 30.2

























