-
Book Overview & Buying
-
Table Of Contents
Python Illustrated
By :
Before we move on to the next topic, let’s quickly review what we learned in this chapter. We discovered the world of object-oriented programming: a way of structuring your code with objects. These objects are instances of classes, the blueprints of data types. Wiesje could, for example, be an instance of the Dog class. When creating a class, you specify attributes and methods. Methods are class-specific functions that an object can perform, and attributes are the data each object of that class holds.
By defining classes, instead of creating every object separately, you decrease the chance of errors with forgotten keys or accidental typos, and you give your data type a name. Also, it allows you to create multiple objects with a lot more ease (reusability), and you can specify functionality for a specific class using methods!
Okay, so classes are great. But how do you define one? Well, with the class keyword. It’s pretty straightforward, but things get...