Page 226 -
P. 226
get some class
Define a class
Python follows the standard object-oriented programming model of
providing a means for you to define the code and the data it works on as a
class. Once this definition is in place, you can use it to create (or instantiate)
data objects, which inherit their characteristics from your class.
Within the object-oriented world, your code is often referred to as the class’s
methods, and your data is often referred to as its attributes. Instantiated
data objects are often referred to as instances.
The “raw” data
"Sarah Sweeney","2002-6-17",[2:58,2.58,2:39,2-25,2-55,2:54,2.18,2:55,2:55,2:22,2-21,2.22]
The factory has been
primed with your class.
The Object
Factory
Here are your instantiated objects,
which are packaged to contain your
code and its associated data.
Mikey’s object instance James’s object
Julie’s object instance
instance
Each object is created from the class and shares a similar set of
characteristics. The methods (your code) are the same in each instance, but
each object’s attributes (your data) differ because they were created from your
raw data.
Let’s look at how classes are defined in Python.
190 Chapter 6