Acknowledgments |
|
xv | |
Introduction |
|
1 | (4) |
|
Who Should Read This Book and Why |
|
|
2 | (1) |
|
|
2 | (3) |
|
|
5 | (10) |
|
|
5 | (2) |
|
|
7 | (1) |
|
|
7 | (1) |
|
|
8 | (1) |
|
|
8 | (2) |
|
Coding Style and Automated Checks |
|
|
10 | (3) |
|
Tools to Catch Style Errors |
|
|
11 | (1) |
|
Tools to Catch Coding Errors |
|
|
12 | (1) |
|
|
13 | (2) |
|
2 Modules, Libraries, and Frameworks |
|
|
15 | (18) |
|
|
16 | (4) |
|
|
17 | (1) |
|
|
18 | (1) |
|
|
18 | (1) |
|
|
19 | (1) |
|
Useful Standard Libraries |
|
|
20 | (2) |
|
|
22 | (2) |
|
The External Libraries Safety Checklist |
|
|
23 | (1) |
|
Protecting Your Code with an API Wrapper |
|
|
23 | (1) |
|
Package Installation: Getting More from pip |
|
|
24 | (2) |
|
Using and Choosing Frameworks |
|
|
26 | (1) |
|
Doug Hellmann, Python Core Developer, on Python Libraries |
|
|
27 | (6) |
|
3 Documentation and Good Api Practice |
|
|
33 | (16) |
|
|
34 | (11) |
|
Getting Started with Sphinx and reST |
|
|
35 | (1) |
|
|
36 | (3) |
|
Writing a Sphinx Extension |
|
|
39 | (1) |
|
Managing Changes to Your APIs |
|
|
40 | (1) |
|
|
41 | (1) |
|
Documenting Your API Changes |
|
|
41 | (2) |
|
Marking Deprecated Functions with the warnings Module |
|
|
43 | (2) |
|
|
45 | (1) |
|
Christophe de Vienne on Developing APIs |
|
|
45 | (4) |
|
4 Handling Timestamps and Time Zones |
|
|
49 | (8) |
|
The Problem of Missing Time Zones |
|
|
50 | (1) |
|
Building Default datetime Objects |
|
|
50 | (2) |
|
Time Zone-Aware Timestamps with dateutil |
|
|
52 | (2) |
|
Serializing Time Zone-Aware datetime Objects |
|
|
54 | (1) |
|
|
55 | (1) |
|
|
56 | (1) |
|
5 Distributing Your Software |
|
|
57 | (18) |
|
A Bit of setup.py History |
|
|
58 | (2) |
|
|
60 | (1) |
|
The Wheel Format Distribution Standard |
|
|
61 | (3) |
|
Sharing Your Work with the World |
|
|
64 | (3) |
|
|
67 | (6) |
|
|
68 | (1) |
|
|
69 | (2) |
|
Using Plugins and Drivers |
|
|
71 | (2) |
|
|
73 | (1) |
|
Nick Coghlan on Packaging |
|
|
74 | (1) |
|
|
75 | (24) |
|
|
76 | (14) |
|
|
76 | (2) |
|
|
78 | (1) |
|
|
79 | (2) |
|
Running Tests in Parallel |
|
|
81 | (1) |
|
Creating Objects Used in Tests with Fixtures |
|
|
81 | (2) |
|
|
83 | (1) |
|
Controlled Tests Using Mocking |
|
|
84 | (4) |
|
Revealing Untested Code with coverage |
|
|
88 | (2) |
|
|
90 | (6) |
|
Setting Up a Virtual Environment |
|
|
91 | (1) |
|
Using virtualenv with tox |
|
|
92 | (2) |
|
Re-creating an Environment |
|
|
94 | (1) |
|
Using Different Python Versions |
|
|
95 | (1) |
|
|
95 | (1) |
|
|
96 | (1) |
|
Robert Collins on Testing |
|
|
97 | (2) |
|
|
99 | (20) |
|
Decorators and When to Use Them |
|
|
100 | (7) |
|
|
100 | (1) |
|
|
101 | (1) |
|
|
102 | (1) |
|
|
103 | (4) |
|
How Methods Work in Python |
|
|
107 | (1) |
|
|
108 | (1) |
|
|
109 | (1) |
|
|
110 | (2) |
|
Mixing Static, Class, and Abstract Methods |
|
|
112 | (5) |
|
Putting Implementations in Abstract Methods |
|
|
114 | (1) |
|
|
114 | (3) |
|
|
117 | (2) |
|
|
119 | (16) |
|
|
120 | (1) |
|
|
121 | (4) |
|
|
121 | (2) |
|
Returning and Passing Values with yield |
|
|
123 | (1) |
|
|
124 | (1) |
|
|
125 | (1) |
|
Functional Functions Functioning |
|
|
126 | (8) |
|
Applying Functions to Items with map() |
|
|
127 | (1) |
|
Filtering Lists with filter() |
|
|
127 | (1) |
|
Getting Indexes with enumerate() |
|
|
127 | (1) |
|
Sorting a List with sorted() |
|
|
128 | (1) |
|
Finding Items That Satisfy Conditions with any() and all() |
|
|
128 | (1) |
|
Combining Lists with zip() |
|
|
129 | (1) |
|
|
129 | (3) |
|
Useful itertools Functions |
|
|
132 | (2) |
|
|
134 | (1) |
|
9 The Abstract Syntax Tree, Hy, and Lisp-Like Attributes |
|
|
135 | (16) |
|
|
136 | (4) |
|
Writing a Program Using the AST |
|
|
137 | (1) |
|
|
138 | (1) |
|
|
139 | (1) |
|
Extending flake8 with AST Checks |
|
|
140 | (5) |
|
|
141 | (1) |
|
|
141 | (1) |
|
Checking for the Correct Decorator |
|
|
142 | (1) |
|
|
143 | (2) |
|
A Quick Introduction to Hy |
|
|
145 | (2) |
|
|
147 | (1) |
|
Paul Tagliamonte on the AST and Hy |
|
|
147 | (4) |
|
10 Performances and Optimizations |
|
|
151 | (26) |
|
|
152 | (2) |
|
Understanding Behavior Through Profiling |
|
|
154 | (4) |
|
|
154 | (2) |
|
Disassembling with the dis Module |
|
|
156 | (2) |
|
Defining Functions Efficiently |
|
|
158 | (1) |
|
|
159 | (3) |
|
|
162 | (5) |
|
|
167 | (2) |
|
|
169 | (1) |
|
Achieving Zero Copy with the Buffer Protocol |
|
|
170 | (4) |
|
|
174 | (1) |
|
Victor Stinner on Optimization |
|
|
174 | (3) |
|
11 Scaling and Architecture |
|
|
177 | (10) |
|
Multithreading in Python and Its Limitations |
|
|
178 | (1) |
|
Multiprocessing vs. Multithreading |
|
|
179 | (2) |
|
Event-Driven Architecture |
|
|
181 | (1) |
|
Other Options and asyncio |
|
|
182 | (2) |
|
Service-Oriented Architecture |
|
|
184 | (1) |
|
Interprocess Communication with ZeroMQ |
|
|
185 | (1) |
|
|
186 | (1) |
|
12 Managing Relational Databases |
|
|
187 | (14) |
|
RDBMSs, ORMs, and When to Use Them |
|
|
187 | (3) |
|
|
190 | (1) |
|
Streaming Data with Flask and PostgreSQL |
|
|
190 | (5) |
|
Writing the Data-Streaming Application |
|
|
191 | (2) |
|
|
193 | (2) |
|
Dimitri Fontaine on Databases |
|
|
195 | (6) |
|
|
201 | (14) |
|
Using six for Python 2 and 3 Support |
|
|
201 | (2) |
|
|
202 | (1) |
|
Handling Python Modules Moves |
|
|
203 | (1) |
|
|
203 | (1) |
|
Using Python Like Lisp to Make a Single Dispatcher |
|
|
203 | (4) |
|
Creating Generic Methods in Lisp |
|
|
204 | (1) |
|
Generic Methods with Python |
|
|
205 | (2) |
|
|
207 | (3) |
|
Less Boilerplate with attr |
|
|
210 | (3) |
|
|
213 | (2) |
Index |
|
215 | |