Python · The Python Data Model · Intermediate · 28 min read
Python Special Methods for Containers: Sequences, Mappings, Slicing and the collections.abc Mixins
Build custom containers that behave like built-ins. Learn the sequence and mapping protocols, __getitem__ with integers and slices, __len__, __contains__, __iter__, mutation methods, __missing__, using collections.abc base classes to get mixin methods for free, UserDict versus subclassing dict, and design guidance for ring buffers, case-insensitive mappings and matrices.
Create an account to start
Create a free account to see what this lesson covers
- Every free lesson in every section, in full
- Track your progress and pick up where you left off
- Free practice questions and an incident simulation
- Takes under a minute: name, email and a password
No card needed. Full access to Python is a paid upgrade you can choose later.