Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
This chapter introduced the basics of coding classes in Python.
We studied the syntax of the class
statement, and we saw how to use it to build up a class inheritance
tree. We also studied how Python automatically fills in the first
argument in method functions, how attributes are attached to objects
in a class tree by simple assignment, and how specially named operator
overloading methods intercept and implement built-in operations for
our instances (e.g., expressions and printing).
Now that we’ve learned all about the mechanics of coding classes in Python, the next chapter turns to a larger and more realistic example that ties together much of what we’ve learned about OOP so far. After that, we’ll continue our look at class coding, taking a second pass over the model to fill in some of the details that were omitted here to keep things simple. First, though, let’s work through a quiz to review the basics we’ve covered so far.