Classes and attributes

Actual photo of a python class, circa 2007, colorized

Classes contain attributes. Attributes are pieces of data shared by the whole class. These can be of any data type that the programmer desires. There are several types of attributes. One of the most common is an instance attribute. An instance attribute can only be accessed within the scope of a particular instance of a given class, and not by any other instances. This is different from a class attribute which applies to all instances and can be accessed globally. This choice is useful because some data and some functions are useful in any instance of a class and sometimes only in one. Attributes are created by declaring them inside of the class and assigning them a value. When creating a new instance of a given class, you would use the __init__ method to do so. All of these features are very useful in creating classes and attributes in python.