Copyright © 2005-2009 Shalabh Chaturvedi
About This Book
Explains the mechanics of object attribute access for new-style Python objects:
how functions become methods
how descriptors and properties work
determining method resolution order
New-style implies Python version 2.2 and upto and including 3.x. There have been some behavioral changes during these version but all the concepts covered here are valid.
This book is part of a series:
Python Attributes and Methods [you are here]
This revision:
Discuss
| Latest version
| Cover page
Author: shalabh@cafepy.com
Table of Contents
List of Figures
List of Examples
- 1.1. Simple attribute access
- 1.2. A function is more
- 1.3. A simple descriptor
- 1.4. Using a descriptor
- 1.5. Non-data descriptors
- 1.6. Hiding a method
- 1.7. Built-in descriptors
- 1.8. More on properties
- 2.1. Usual base call technique
- 2.2. Base call technique fails
- 2.3. Making a "Who's Next" list
- 2.4. Call next method technique
- 2.5. One super technique
- 2.6. Using super with a class method
- 2.7. Another super technique
- 3.1. Special methods work on type only
- 3.2. Forwarding special method to instance
- 3.3. Subclassing <type 'list'>
- 3.4. Using
__slots__for optimization - 3.5. Customizing creation of subclasses