Defining a class
When your program has several things with the same shape and the same behavior, you define a class to describe the pattern once. The class body declares attributes (the data each instance will hold) and methods (the operations the instance can perform).
class Dog: introduces the class. Inside the body, def bark(self): defines a method. The method gets called on an instance, and the instance is passed in as the first argument by Python automatically.
Classes are the way Python lets you define a new type. Once you have a Dog class, you can build dogs, ask them to bark, store them in lists. The class itself is also an object, just one whose role is to be the template.