About the Author |
|
ix | |
About the Technical Reviewer |
|
xi | |
Acknowledgments |
|
xiii | |
Introduction |
|
xv | |
|
|
1 | (22) |
|
Chapter 1 What Is a Descriptor? |
|
|
3 | (2) |
|
Data Descriptors vs. Nondata Descriptors |
|
|
3 | (1) |
|
The Use of Descriptors by Python |
|
|
4 | (1) |
|
|
4 | (1) |
|
Chapter 2 The Descriptor Protocol |
|
|
5 | (2) |
|
___get___(self, instance, owner) |
|
|
5 | (1) |
|
___set___(self, instance, value) |
|
|
6 | (1) |
|
___delete___(self, instance) |
|
|
6 | (1) |
|
|
6 | (1) |
|
Chapter 3 What Are Descriptors Good For? |
|
|
7 | (2) |
|
|
7 | (1) |
|
Reuse of Read/Write Patterns |
|
|
7 | (1) |
|
|
7 | (1) |
|
|
7 | (1) |
|
Writing for the Class Level |
|
|
8 | (1) |
|
Hiding Function Calls Within Attribute Access |
|
|
8 | (1) |
|
|
8 | (1) |
|
|
8 | (1) |
|
Chapter 4 Descriptors in the Standard Library |
|
|
9 | (6) |
|
|
9 | (2) |
|
|
11 | (1) |
|
|
12 | (1) |
|
|
12 | (1) |
|
|
13 | (2) |
|
Chapter 5 Attribute Access and Descriptors |
|
|
15 | (8) |
|
|
15 | (3) |
|
|
18 | (2) |
|
|
20 | (1) |
|
The Reasoning Behind Data vs. Nondata Descriptors |
|
|
20 | (1) |
|
|
21 | (2) |
|
Part II Making Descriptors |
|
|
23 | (38) |
|
Chapter 6 Which Methods Are Needed? |
|
|
25 | (4) |
|
When ___get___() Is Called Without instance |
|
|
25 | (1) |
|
Raise Exception or Return self |
|
|
26 | (1) |
|
|
26 | (2) |
|
|
28 | (1) |
|
Chapter 7 Storing the Attributes |
|
|
29 | (12) |
|
|
29 | (1) |
|
Storing Data on the Descriptor |
|
|
30 | (3) |
|
Storing on the Instance Dictionary |
|
|
33 | (2) |
|
|
35 | (1) |
|
Indirectly Asking for the Location |
|
|
36 | (1) |
|
|
37 | (1) |
|
|
38 | (1) |
|
Letting the User Take Care of It |
|
|
39 | (1) |
|
|
40 | (1) |
|
|
40 | (1) |
|
Chapter 8 Read-Only Descriptors |
|
|
41 | (6) |
|
|
41 | (1) |
|
|
42 | (1) |
|
|
42 | (1) |
|
|
43 | (2) |
|
|
45 | (2) |
|
Chapter 9 Writing ___delete___() |
|
|
47 | (2) |
|
|
47 | (2) |
|
Chapter 10 Descriptors are Classes Too |
|
|
49 | (4) |
|
|
49 | (1) |
|
|
49 | (1) |
|
Optional/Default Parameters |
|
|
50 | (1) |
|
Descriptors on Descriptors |
|
|
50 | (1) |
|
Passing an Instance Around |
|
|
50 | (1) |
|
Descriptors Just Abstract Method Calls |
|
|
50 | (1) |
|
|
51 | (2) |
|
Chapter 11 Reusing the Wheel |
|
|
53 | (6) |
|
|
53 | (2) |
|
|
55 | (1) |
|
Simple Unbound Attributes |
|
|
56 | (1) |
|
|
57 | (2) |
|
Chapter 12 Other Uses of Descriptors in the World |
|
|
59 | (2) |
|
|
59 | (1) |
|
|
59 | (1) |
|
|
60 | (1) |
|
|
60 | (1) |
|
|
60 | (1) |
Bibliography |
|
61 | (2) |
Index |
|
63 | |