The Hacker’s Guide To Python

 Contents

Starting your project . Pthon versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Project laout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Version numbering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Coding stle & automated checks . . . . . . . . . . . . . . . . . . . . . . Modules and libraries . The import sstem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Standard libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . External libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Interview with Doug Hellmann . . . . . . . . . . . . . . . . . . . . . . . . . Managing API changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Interview with Christophe de Vienne . . . . . . . . . . . . . . . . . . . . Documentation . Getting started with Sphinx and reST . . . . . . . . . . . . . . . . . . . .

CONTENTS

ii

. Sphinx modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Extending Sphinx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Distribution . A bit of histor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Packaging with pbr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Wheel format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Package installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sharing our work with the world . . . . . . . . . . . . . . . . . . . . . . . Interview with Nick Coghlan . . . . . . . . . . . . . . . . . . . . . . . . . . . Entr points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . Visualising entr points . . . . . . . . . . . . . . . . . . . . . . . . . . Using console scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . Using plugins and drivers . . . . . . . . . . . . . . . . . . . . . . .

Virtual environments

Unit testing . The basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Fixtures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Mocking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Test streaming and parallelism . . . . . . . . . . . . . . . . . . . . . . . . . Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using virtualenv with tox . . . . . . . . . . . . . . . . . . . . . . . . . . . .

CONTENTS

iii

. Testing polic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Interview with Robert Collins . . . . . . . . . . . . . . . . . . . . . . . . .

Methods and decorators . Creating decorators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How methods work in Pthon . . . . . . . . . . . . . . . . . . . . . . . . . . Static methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Class method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Abstract methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Mixing static, class, and abstract methods . . . . . . . . . . . . . . . . . . The truth about super . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Functional programming . Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . List comprehensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Functional functions functioning . . . . . . . . . . . . . . . . . . . . . . .

The AST . H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Interview with Paul Tagliamonte . . . . . . . . . . . . . . . . . . . . . . .

Performances and optimizations . Data structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Profiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ordered list and bisect . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

CONTENTS

iv

. Namedtuple and slots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Memoiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Achieving ero cop with the buffer protocol . . . . . . . . . . . . . . . . Interview with Victor Stinner . . . . . . . . . . . . . . . . . . . . . . . . .

Scaling and architecture . A note on multi-threading . . . . . . . . . . . . . . . . . . . . . . . . . . . . Multiprocessing vs multithreading . . . . . . . . . . . . . . . . . . . . . . . Asnchronous and event-driven architecture . . . . . . . . . . . . . . . . Service-oriented architecture . . . . . . . . . . . . . . . . . . . . . . . . .

RDBMS and ORM . Streaming data with Flask and PostgreSQL . . . . . . . . . . . . . . . . . Interview with Dimitri Fontaine . . . . . . . . . . . . . . . . . . . . . . . .

Python support strategies . Language and standard librar . . . . . . . . . . . . . . . . . . . . . . . . . External libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using six . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Write less, code more . Single dispatcher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Context managers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download