Code Clinic - The Build - Book 8: Advanced OOP & Inheritance
Python objects get better at two things: remembering, and sharing. This book covers both. It opens with objects that hold several attributes at once, and with default attributes, values a new object starts with unless you say otherwise, which keeps your setup short and your objects consistent. Counters follow, using += so an object can track something that changes across many calls. That leads to state, the idea that an object's data moves through stages during its life, and to method chaining, where a method returns the object so several calls join into one readable line. Then lists of objects drawn from several classes, held and looped over together. The second half is inheritance. You start from the problem that causes it, the same block of code copied into three classes, and then fix it: a parent class holds what they share, child classes inherit it for free, and super() plus overriding lets a child extend a parent method or replace it outright. This is how large systems stop repeating themselves.
Nineteen A4 pages, in full colour. Written in short sentences and plain English, for readers whose first language is not English and clearer for everyone else because of it.
Every Python code example in this book was run before the page was printed, so the output you read is the output you get. Instant PDF download. By M.R. Sterling.