The Hacker's Guide to Python (3rd Edition) cover

The Hacker's Guide to Python (3rd Edition)

No rating yet
Chapters
40
ISBN
9787115437105

Tags

Summary

The Hacker's Guide to Python (3rd Edition) is an advanced book by French free-software developer Julien Danjou for readers who already have some experience with Python; the original title is The Hacker's Guide to Python. The book does not teach introductory Python syntax. Its starting point is that many people can write scripts that run, but turning Python into maintainable, distributable, and testable engineering projects requires a different kind of experience. The author has long been involved in Debian, GNU Emacs, the awesome window manager, and the OpenStack Ceilometer project. Working on a project like OpenStack, with over a million lines of Python code and hundreds of developers, led him to systematically summarize practices for using Python in an engineering context. The book begins with the organizational structure, version numbering, and coding style involved in starting a new project, then covers module and library management, handling API changes, time zone pitfalls, writing documentation with Sphinx, packaging and distribution, virtual environments, unit testing and mocking, decorators and method mechanics, functional programming, abstract syntax trees, performance optimization, plug-in architecture, RDBMS and ORM, and Python 3 support strategy. It concludes with the principle that less is more and includes suggestions for further reading. The book also intersperses interviews with several open-source community experts. This is the Chinese translation of the 3rd edition, translated by Wang Feilong, 216 pages in total.

Editor's review

市面上讲 Python 的书,大多花大量篇幅在做“如何写”这件事:语法、类型、控制流、标准库。真正让人卡住的往往不是这些,而是项目做大之后的另一类问题——代码怎么组织、版本怎么发、文档怎么生成、测试怎么写、性能从哪里下手、要不要给旧接口做兼容。《Python高手之路》恰好补的就是这一段空白,而且补得很实在:作者不是站在讲台上总结方法论,而是在 OpenStack 这样的超大代码库里踩过坑之后把经验写下来。它的章节顺序也很有意思,从“项目开始”一路走到“分发”“文档”“测试”“性能”“架构”,几乎就是一个 Python 项目的完整生命周期。第3版更新了与 Python 3 相关的支持策略与工具链内容,篇幅仍然控制在两百多页,不厚,不拖泥带水。译文流畅,术语处理稳妥。对于已经能写脚本、但还不确定一个“正经的 Python 项目”该长什么样的开发者,这本书能帮你把很多零散的做法连成体系。

Who it's for

A good fit for

  • 已掌握 Python 基础语法、能独立写脚本,想进阶到工程化开发的人
  • 需要维护长期演进的项目,正在被版本、文档、测试问题困扰的开发者
  • 参与或准备参与 OpenStack 等大型开源项目的工程师
  • 想了解 Python 打包分发、插件化架构与性能优化做法的技术负责人

Not a good fit for

  • 完全没有编程基础、想从零学 Python 语法的读者
  • 只想查标准库用法、寻找 API 速查手册的人
  • 希望书里有大量完整商业级项目实战案例的读者

Reading tips

  1. 先通读第1到第7章,把项目结构、打包分发、虚拟环境的链条搭起来,这是全书的地基。
  2. 第8章单元测试与第12章性能优化最值得逐字精读,并对着自己现有的代码动手重写一遍。
  3. 第9至11章涉及装饰器、函数式编程与 AST,可先了解概念,遇到相关需求时再回来细读。
  4. 书中专家访谈部分可当补充读物,顺着访谈里提到的开源项目去读源码,收获会比预期大。

About the publisher

Posts & Telecom Press China · Founded in 1953

Posts & Telecom Press is known for its strengths in science and technology, computing, and information and communications titles, and has extended its publishing into photography, art, software learning, and inspirational growth, giving it a fairly diverse range. Its catalog includes computing and communications works such as Refactoring and Patterns (Revised Edition) and Huawei Switch Learning Guide (Second Edition), alongside bilingual collector's editions such as The Little Prince (Chinese-English-French illustrated collector's edition), The Great Gatsby, and Three Days to See. Beijing Ten Years: 1980-1990 and Ghost Blade: WLOP Personal Illustration Collection reflect its presence in photography and art. Its authors include Antoine de Saint-Exupéry, Helen Keller, Joshua Kerievsky, Wang Da, Zhang Zhaozeng, and WLOP.

Contents

  1. Chapter 1 Starting a Project
  2. 1.1 Python Versions
  3. 1.2 Project Layout
  4. 1.3 Version Numbering
  5. 1.4 Coding Style and Automated Checks
  6. Chapter 2 Modules and Libraries
  7. 2.1 The Import System
  8. 2.2 The Standard Library
  9. 2.3 External Libraries
  10. 2.4 Frameworks
  11. Chapter 3 Managing API Changes
  12. Chapter 4 Time Zone Pitfalls
  13. Chapter 5 Documentation
  14. 5.1 Getting Started with Sphinx and reST
  15. 5.2 Sphinx Modules
  16. 5.3 Extending Sphinx
  17. Chapter 6 Distribution
  18. 6.1 A Brief History
  19. 6.2 Packaging with pbr
  20. 6.3 The Wheel Format
  21. 6.4 Installing Packages
  22. 6.5 Sharing Your Work with the World
  23. 6.7 Entry Points
  24. Chapter 7 Virtual Environments
  25. Chapter 8 Unit Testing
  26. 8.1 Basics
  27. 8.2 Fixtures
  28. 8.3 Mocking
  29. 8.4 Scenario Testing
  30. 8.5 Test Sequences and Parallelism
  31. 8.6 Test Coverage
  32. 8.7 Using Virtual Environments and tox
  33. 8.8 Testing Strategy
  34. Chapter 9 Methods and Decorators
  35. 9.1 Creating Decorators
  36. 9.2 How Methods Work in Python
  37. Chapter 10 Functional Programming
  38. Chapter 11 Abstract Syntax Trees
  39. Chapter 12 Performance and Optimization
  40. Chapter 13 Extensions and Architecture

FAQ

这本书适合零基础学 Python 的人吗?
不适合。作者在开篇就假定读者已经使用 Python 一段时间了,书中没有关键字讲解,也没有 for 循环示例,更不会细讲标准库。零基础读者应先看入门教材,再回到这本书。
书名里的“高手”是指语法高手吗?
不是。这本书讲的是工程实践能力:项目结构、模块管理、文档、分发、虚拟环境、测试、性能与架构。作者认为这些才是从“会写”到“写得好”的分水岭。
第3版和之前版本有什么区别?
据作者前言,第3版根据第1版发布后的变化做了更新,补充了 Python 3 支持策略等内容。中译本为人民邮电出版社 2016 年出版,王飞龙翻译,共 216 页。
书里为什么要讲 OpenStack?
作者是 OpenStack 项目 Ceilometer 的技术负责人,在数百名开发者、上百万行代码的项目中工作,让他看到自动化测试、文档、分发在真实规模下为何必不可少,书中的经验多来自这一背景。
读完能解决实际项目里的什么问题?
比较典型的是:项目目录怎么摆、包怎么发到 PyPI、文档如何用 Sphinx 生成、测试怎么组织用 tox、出了问题怎么定位性能瓶颈、插件化架构如何设计。这些都能直接套到自己的项目上。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

Top rated in the same category