Python Cookbook, 3rd Edition (Chinese Edition) cover

Python Cookbook, 3rd Edition (Chinese Edition)

Rating 4.6
Word count
914K words
Chapters
15
Series
Python Cookbook (3rd Edition, Chinese Edition)
ISBN
9787115379597

Tags

Summary

Python Cookbook, 3rd Edition (Chinese Edition) is the Python volume in O'Reilly's classic Cookbook series. The original third edition was written by David Beazley and Brian K. Jones, and the Chinese edition was translated by Chen Ge and published by Posts & Telecom Press in 2015. The book is organized around a "Problem, Solution, Discussion" structure, with 15 chapters and more than a hundred topics, and all example code was written and tested under Python 3.3. It covers data structures and algorithms, strings and text, numbers, dates and times, iterators and generators, files and I/O, data encoding and processing, functions, classes and objects, metaprogramming, modules and packages, network and web programming, concurrency, useful scripts and system administration, testing, debugging and exceptions, and C extensions. Each section first states the problem to be solved, then gives code that can be used directly, and finally explains why the code works and what its limitations and alternatives are. Unlike introductory tutorials, this book does not teach the basics of Python syntax; it focuses instead on idiomatic modern Python: context managers, decorators, generators, descriptors, metaclasses, asyncio and other concurrency approaches, and lesser-known modules in the standard library. In the preface, the authors explain that they favored topics that demonstrate general programming techniques (that is, programming patterns) rather than only very narrow, specific problems, and that they deliberately included many features new in Python 3 relative to Python 2 that even experienced programmers may not know well. Readers can read it chapter by chapter or look up the chapter matching their specific problem.

Editor's review

很多 Python 书教你怎么写代码,这本书教你怎么“写好”代码。它延续 Cookbook 系列“问题—方案—讨论”的经典体例:先告诉你这一节要解决什么麻烦,再给出可以直接拿去用的代码,最后说明它为什么能工作、在什么情况下会失效。对有一定经验的开发者来说,最有价值的往往是最后那一部分——它把“能跑”变成“知道为什么能跑”。 第 3 版是一次彻底的改写,全部示例在 Python 3.3 下测试,选材偏向现代工具和惯用写法:生成器与迭代协议、装饰器与闭包、描述符与元类、asyncio 与其他并发路线、标准库里那些少有人用的角落。译者陈舸的译文术语统一、语句干净,代码排版保留了原书的可读性。 它不适合当作从头读到尾的教程,更适合放在手边:遇到具体问题翻一节,顺手把周边的写法也看一遍。读完你会发现,自己对 Python 语言机制的直觉变准了。

Who it's for

A good fit for

  • 已能熟练写出 Python 代码,想进一步提升的中级开发者
  • 需要从 Python 2 迁移到 Python 3、或想更新旧代码习惯的程序员
  • 做数据处理、网络服务、系统脚本,经常需要“具体怎么写”的人
  • 想理解生成器、装饰器、描述符、元类等语言机制的读者

Not a good fit for

  • 第一次学编程或第一次接触 Python 的零基础读者
  • 期望按章节循序渐进、配有大量习题的教材型读者
  • 只想找一份模块函数速查表当手册用的人

Reading tips

  1. 第一遍不求全读:先挑与当前工作相关的章节,边读边把示例跑一遍
  2. 每节读完试着改一行代码,观察报错信息,比照书中“讨论”部分对照理解
  3. 把常翻的几章(数据结构、函数、类与对象、并发)贴上标签,作为长期案头参考
  4. 注意书中的示例基于 Python 3.3,练习时留意标准库在这些年里的变化

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 Data Structures and Algorithms
  2. Chapter 2 Strings and Text
  3. Chapter 3 Numbers, Dates, and Times
  4. Chapter 4 Iterators and Generators
  5. Chapter 5 Files and I/O
  6. Chapter 6 Data Encoding and Processing
  7. Chapter 7 Functions
  8. Chapter 8 Classes and Objects
  9. Chapter 9 Metaprogramming
  10. Chapter 10 Modules and Packages
  11. Chapter 11 Network and Web Programming
  12. Chapter 12 Concurrency
  13. Chapter 13 Utility Scripts and System Administration
  14. Chapter 14 Testing, Debugging, and Exceptions
  15. Chapter 15 C Extensions

FAQ

这本书适合零基础学 Python 吗?
不适合。原书明确面向已有一定经验的 Python 程序员,默认读者掌握基本语法、数据结构、复杂度、系统编程乃至 C 语言等背景知识,不会讲解入门内容。零基础读者建议先读完一本入门教程再来。
书里的代码是什么 Python 版本?现在还适用吗?
全部示例在 Python 3.3 环境下编写并测试。绝大多数关于语言机制和标准库的核心写法至今仍然适用,但部分标准库细节(如 asyncio 相关 API)在后续版本中有增补和调整,动手时请对照当前版本的官方文档。
中文版和原版第 3 版内容一致吗?
中文版依据 O'Reilly 原书第 3 版(2013 年出版,ISBN 978-1-4493-4037-7)翻译,15 章结构与原书对应,由陈舸翻译,人民邮电出版社 2015 年 5 月出版,全书约 914 千字、684 页。
这本书和《流畅的Python》有什么区别?
本书以“某类具体问题怎么解决”为线索,偏实用配方,覆盖领域广;《流畅的Python》则以语言模型和数据模型为主线系统讲解 Python 的设计思路。两者定位不同,常被进阶读者搭配使用:一本查问题,一本正观念。
可以当速查手册用吗?
不太适合。原书前言特别说明本书不是快速参考手册,不用于查某个模块有哪些函数。它按编程主题组织,重在展示解决方案并引导你继续查阅在线资料和官方文档。

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.

More by the same author

Top rated in the same category