Summary

In this chapter, we've seen the basics of defining a class and using objects of that class. We've looked at how we create the methods that define the behavior of a class. The internal state of the class is the result of the various methods: in Python we don't formally declare instance variables. We generally rely in the __init__() method to provide the initial or default values for the object's state.

We've looked at the way Python resolves attribute and method names by searching the object, the class, and then the superclasses. The method resolution order is based on the order the classes are presented in the initial class statement.

The @properties decorator can be used to create methods that have the same syntax as an attribute. This ...

Get Python Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.