【实例简介】
2015新书-Python高手之路(英文原版)-完整目录
CONTENTS
3.2 Sphinx modules
鲁····音
43
3.3 Extending Sphinx
47
4 Distribution
50
4.1 A bit of history
50
4.2 Packaging with pbr
53
4.3 The Wheel format
55
4.4 Package installation
57
4.5 Sharing your work with the world
59
4.6 Interview with Nick Coghlan
,,,,,,64
4.7 Entry points
66
4.7.1 Visualising entry points
67
4.7.2 Using console scripts
68
4.7.3 Using plugins and drivers
71
5 Virtual environments
75
6 Unit testing
82
6.1 The basics
82
6.2 Fixtures
91
6. 3 Mocking
鲁鲁····鲁番鲁
鲁鲁鲁
92
6.4 Scenarios
,,,,,98
6.5 Test streaming and parallelism
102
6.6 Coverage
107
6.7 Using virtualeny with tox..........
,,,111
CONTENTS
6.8 Testing policy......,.
116
6.9 Interview with robert collins
.,..117
7 Methods and decorators
121
7.1 Creating decorators
,,,121
7.2 How methods work in Python
128
7.3 Static methods
,,,,131
7. 4 Class method
.,,,,,132
7.5 Abstract methods
,,,,,,,,,,133
7.6 Mixing static, class, and abstract methods
,,,135
7.7 The truth about super
138
8 Functional programming
143
8.1 Generators.,,,,,,,,,,,,,
··········
·鲁
144
8.2 List comprehensions
,,,,,,,,150
8. 3 Functional functions functioning
151
9 The ast
161
9.1 Hy
春·香
,.,,,165
9.2 Interview with Paul tagliamonte
···音
167
10 Performances and optimizations
173
10.1 Data structures
173
10.2 Profiling
,,,,,175
10.3 Ordered list and bisect
182
CONTENTS
10.4 Namedtuple and slots
184
10.5 Memoization
.....191
10.6 PyPy
193
10.7 Achieving zero copy with the buffer proto col
,,,195
10. 8 Interview with victor stinger
202
11 Scaling and architecture
205
11 A note on multi- threading.··
.,,,,.205
11.2 Multiprocessing vs multithreading
208
11. 3 Asynchronous and event-driven architecture
,,,210
11.4 Service-oriented architecture
215
12 RDBMS and oRM
219
12.1 Streaming data with Flask and PostgreSQL
223
12.2 Interview with Dimitri Fontaine,..,,,,, 230
13 Python 3 support strategies
241
13. 1 Language and standard library
,,,243
13.2 External libraries
246
13. 3 Using six
···音
247
14 Write less code more
251
14.1 Single dispatcher
251
14.2 Context managers
,,,,,257
List of Figures
1 Standard package directory
6.1 Coverage of ceilometer. publisher
,,,110
10.1 CAche grind example
,.177
10.2 Using slice on memoryview objects
198
13.1 Python 2 base classes
244
13.2 Python 3 base classes
,,,,,245
List of Examples
1.1 A pep& run
8
1.2 Running pep8 with -ignore
2.1 Hy module importer
13
2.2 A documented aPi change
32
2.3 a documented API change with warning
33
2. 4 Running python -W error
34
3.1 Code from sphinxcontrib pecanwsme. rest. setup
48
4.1 setup. py using distutils
·······.·········
50
4.2 setup. py using setuptools
51
4.3 Using setup. py sdist
59
4.4 Result of epi group list
67
4.5 Result of epi group show console_scripts
67
4.6 Result of epi ep show console_ scripts coverage
68
4.7 A console script generated by setuptools
70
4.8 Running pytimed
聊看鲁
,,,73
5.1 Automatic virtual environment creation ..................77
5.2 Boostraping a venv environment
78
6.1 A really simple test in test true. py
83
6.2 Failing a test
88
6.3 Skipping tests......
88
LIST OF EXAMPLES
6.4 Using setUp with unittest
90
6.5 Using fixtures. EnvironmentVariable
92
6.6 Basic mock usage
93
6.7 Checking method calls
94
6.8 Using mock patch
95
6.9 Using mock patch to test a set of behaviour
95
6.10 testscenarios basic usage
99
6.11 Using testscenarios to test drivers
101
6.12 Using subunit2pyunit
··········
102
6.13A test conf file
105
6. 14 Running test run
parallel
106
6.15 Using nosetests --with-coverage
,,,108
6. 16 Using coverage with testrepository
,,,111
6.17 A. travis yml example file
117
7.1 A registering decorator
122
7.2 Source code of functools update wrapper in Python 3.3
,,,125
7.3 Using functoolswraps
,,,126
7.4 Retrieving function arguments using inspect
127
7.5 A Python 2 method
128
7.6 A Python 3 method
,,,,128
7.7 Calling unbound get_size in Python 2
129
7.8 Calling unbound get_size in Python 3
129
7.9 Calling bound get size
····章
130
7.10 @staticmethod usage......
,,,131
7.11 Implementing an abstract method
..134
7.12 Implementing an abstract method using abc
134
7. 13 Mixing @clas method and @abstractmethod
136
7. 14 USing super()with abstract methods.......... 137
LIST OF EXAMPLES
8.1 yield returning a value
148
8.2 filter usage in Python 3
,,,,,,152
8.3 Using first
156
8.4 Using the operator module with itertools groupby
,,,160
9.1 Parsing Python code to AST
春·鲁自···
,,,161
9.2 Hello world using Python AST
......163
9.3 Changing all binary operation to addition
164
10.1 Using the pRofile module
175
10.2 Using cAche Grind to visualize Python profiling data
176
10.3 A function defined in a function disassembled
180
10.4 Disassembling a closure
181
10.5 Usage of bisect
,,,182
10.6 Usage of bisectinsort
,,,183
10.7 A SortedList implementation
183
10. 8 A class declaration using slots
,188
10.9 Memory usage of objects using slots
188
10. 10 Declaring a class using namedtuple
189
10.11 Memory usage of a class built from collections. namedtuple.... 190
10.12A basic memoization technique
,,,191
10.13 Using functools. lru cache
,,,192
11.1 Result of time python worker. py
209
11.2 Worker using multiprocessing
.,.209
1. 3 Result of time python worker. py
····章
209
11. 4 Basic example of using select
,,,211
11.5 Example with pyev
214
12. 1 Creating the message table
223
12.2 The notify _on_insert function
224
12. 3 The trigger for notify_on_insert
,,,225
LIST OF EXAMPLES
12. 4 Receiving notifications in Python
225
12.5 Flask streamer application
,,,,,,227
14.1 Simple implementation of a context object
257
14.2 Simplest usage of contextlib. contextmanager
,,,258
14.3 Using a context manager on a pipeline object
259
14.4 Opening two files at the same time
260
14.5 Opening two files at the same time with one with statement
260
【实例截图】
【核心代码】