5. Constructing Python – Classes and Methods

Overview

By the end of this chapter, you will be able to Use class and instance attributes to distinguish between attributes; use instance methods to perform calculations based on the instance attributes of an object; use static methods to write small utility functions to refactor code in a class to avoid repetition; use property setters to handle the assignment of values to computed properties and perform validation and create classes that inherit methods and attributes from other classes.

Introduction

In Chapter 4, Extending Python, Files, Errors, and Graphs, you began to move beyond the basic and fundamental, into writing defensive code and anticipating potential issues. In this chapter, ...

Get The Python Workshop 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.