Muutke küpsiste eelistusi

Serious Python: Black-Belt Advice on Deployment, Scalability, Testing, and More [Pehme köide]

  • Formaat: Paperback / softback, 240 pages, kõrgus x laius: 234x177 mm
  • Ilmumisaeg: 27-Dec-2018
  • Kirjastus: No Starch Press,US
  • ISBN-10: 1593278780
  • ISBN-13: 9781593278786
Teised raamatud teemal:
  • Formaat: Paperback / softback, 240 pages, kõrgus x laius: 234x177 mm
  • Ilmumisaeg: 27-Dec-2018
  • Kirjastus: No Starch Press,US
  • ISBN-10: 1593278780
  • ISBN-13: 9781593278786
Teised raamatud teemal:
An indispensable collection of practical tips and real-world advice for tackling common Python problems and taking your code to the next level. Features interviews with high-profile Python developers who share their tips, tricks, best practices, and real-world advice gleaned from years of experience.

The Hacker's Guide to Python will teach you how to fine tune your Python code and give you a deeper understanding of how the language works under the hood. This essential guide distills years of Python experience into a handy collection of general advice and specific tips that will help you pick the right libraries, distribute your code correctly, build future-proof programs, and optimize your programs down to the bytecode.

Author Julien Danjou, an OpenStack contributor (the largest open source project written in Python) covers a swath of important areas like scaling, testing, and porting your code. You'll also learn directly from Python experts and get real-world (and time-saving) advice on topics like unit testing, packaging code, performances and optimizations, and designing APIs. Elevate your code and get seriously good at Python with The Hacker's Guide to Python!

Arvustused

"Serious Python contains a considerable amount of judicious battle-tested advice from an experienced developeras well as some insightful gems from the guest contributorsmaking the overall effort a welcome addition to the limited number of books aimed at more advanced Python programmers." Michael J. Ross, web developer and former Slashdot contributor

Muu info

An indispensable collection of practical tips and real-world advice for tackling common Python problems and taking your code to the next level. Features interviews with high-profile Python developers who share their tips, tricks, best practices, and real-world advice gleaned from years of experience.
Acknowledgments xv
Introduction 1(4)
Who Should Read This Book and Why
2(1)
About This Book
2(3)
1 Starting Your Project
5(10)
Versions of Python
5(2)
Laying Out Your Project
7(1)
What to Do
7(1)
What Not to Do
8(1)
Version Numbering
8(2)
Coding Style and Automated Checks
10(3)
Tools to Catch Style Errors
11(1)
Tools to Catch Coding Errors
12(1)
Joshua Harlow on Python
13(2)
2 Modules, Libraries, and Frameworks
15(18)
The Import System
16(4)
The sys Module
17(1)
Import Paths
18(1)
Custom Importers
18(1)
Meta Path Finders
19(1)
Useful Standard Libraries
20(2)
External Libraries
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)
Documenting with Sphinx
34(11)
Getting Started with Sphinx and reST
35(1)
Sphinx Modules
36(3)
Writing a Sphinx Extension
39(1)
Managing Changes to Your APIs
40(1)
Numbering API Versions
41(1)
Documenting Your API Changes
41(2)
Marking Deprecated Functions with the warnings Module
43(2)
Summary
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)
Solving Ambiguous Times
55(1)
Summary
56(1)
5 Distributing Your Software
57(18)
A Bit of setup.py History
58(2)
Packaging with setup.erg
60(1)
The Wheel Format Distribution Standard
61(3)
Sharing Your Work with the World
64(3)
Entry Points
67(6)
Visualizing Entry Points
68(1)
Using Console Scripts
69(2)
Using Plugins and Drivers
71(2)
Summary
73(1)
Nick Coghlan on Packaging
74(1)
6 Unit Testing
75(24)
The Basics of Testing
76(14)
Some Simple Tests
76(2)
Skipping Tests
78(1)
Running Particular Tests
79(2)
Running Tests in Parallel
81(1)
Creating Objects Used in Tests with Fixtures
81(2)
Running Test Scenarios
83(1)
Controlled Tests Using Mocking
84(4)
Revealing Untested Code with coverage
88(2)
Virtual Environments
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)
Integrating Other Tests
95(1)
Testing Policy
96(1)
Robert Collins on Testing
97(2)
7 Methods and Decorators
99(20)
Decorators and When to Use Them
100(7)
Creating Decorators
100(1)
Writing Decorators
101(1)
Stacking Decorators
102(1)
Writing Class Decorators
103(4)
How Methods Work in Python
107(1)
Static Methods
108(1)
Class Methods
109(1)
Abstract Methods
110(2)
Mixing Static, Class, and Abstract Methods
112(5)
Putting Implementations in Abstract Methods
114(1)
The Truth About super
114(3)
Summary
117(2)
8 Functional Programming
119(16)
Creating Pure Functions
120(1)
Generators
121(4)
Creating a Generator
121(2)
Returning and Passing Values with yield
123(1)
Inspecting Generators
124(1)
List Comprehensions
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)
A Common Problem Solved
129(3)
Useful itertools Functions
132(2)
Summary
134(1)
9 The Abstract Syntax Tree, Hy, and Lisp-Like Attributes
135(16)
Looking at the AST
136(4)
Writing a Program Using the AST
137(1)
The AST Objects
138(1)
Walking Through an AST
139(1)
Extending flake8 with AST Checks
140(5)
Writing the Class
141(1)
Ignoring Irrelevant Code
141(1)
Checking for the Correct Decorator
142(1)
Looking for self
143(2)
A Quick Introduction to Hy
145(2)
Summary
147(1)
Paul Tagliamonte on the AST and Hy
147(4)
10 Performances and Optimizations
151(26)
Data Structures
152(2)
Understanding Behavior Through Profiling
154(4)
cProfile
154(2)
Disassembling with the dis Module
156(2)
Defining Functions Efficiently
158(1)
Ordered Lists and bisect
159(3)
Namedtuple and Slots
162(5)
Memoization
167(2)
Faster Python with PyPy
169(1)
Achieving Zero Copy with the Buffer Protocol
170(4)
Summary
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)
Summary
186(1)
12 Managing Relational Databases
187(14)
RDBMSs, ORMs, and When to Use Them
187(3)
Database Backends
190(1)
Streaming Data with Flask and PostgreSQL
190(5)
Writing the Data-Streaming Application
191(2)
Building the Application
193(2)
Dimitri Fontaine on Databases
195(6)
13 Write Less, Code More
201(14)
Using six for Python 2 and 3 Support
201(2)
Strings and Unicode
202(1)
Handling Python Modules Moves
203(1)
The modernize Module
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)
Context Managers
207(3)
Less Boilerplate with attr
210(3)
Summary
213(2)
Index 215
Julien Danjou is a Principal Software Engineer at Red Hat and a contributor to OpenStack, the largest existing open source project written in Python. He has been a Free Software and Open Source hacker for the past 15 years.