Python Standard Library cover

Python Standard Library

No rating yet
Chapters
14
ISBN
9780596000967

Tags

Summary

Python Standard Library is a reference to the standard library written by Fredrik Lundh, a well-known developer in the Python community and author of the Python Imaging Library (PIL), for Python programmers with some experience. Python is a highly modular language, and the functions most frequently used in daily development come largely from the standard library distributed with the interpreter, including basic support modules, operating system interfaces, network protocols, file format handling, data conversion, threads and processes, and data persistence. The book goes through these modules one by one and includes more than three hundred annotated example scripts demonstrating the typical use of each module in real code. Unlike the official reference documentation, which emphasizes interface listings, this book emphasizes "short runnable scripts": the author long answered questions on the comp.lang.python newsgroup and distilled from thousands of questions the most common confusions developers face—not knowing what a module can do, choosing the wrong module, or reinventing the wheel. The book shows solutions directly with examples that are as short, adaptable, and portable as possible. It covers the modules added in Python 2.0 and related changes, and the examples were tested on Windows, Solaris, and Linux. Organized by theme, it moves through core modules, more standard modules, threads and processes, data representation, file formats, mail and news message processing, network protocols, internationalization, multimedia, data storage, tools and utilities, platform-specific modules, implementation support modules, and other modules, with a CD-ROM containing all the example code. As a reference published in 2001, its module information reflects early Python 2.x and differs from today's Python 3 standard library; it is best read as historical material for understanding the design ideas and idioms of the standard library.

Editor's review

很多 Python 学习者会一口气搬回好几本语法书,却在真正写代码时反复去翻在线文档,原因是缺少一份“按用途组织、能直接照着改”的标准库索引。本书正是为补上这一环而写的。作者 Fredrik Lundh 既是 PIL 的作者,也是 Python 新闻组的长期答疑者,他把自己回答过的数千个提问压缩成三百多个短小示例:每个脚本只解决一个问题,注释克制,读者可以按需取用。这种“代码优先、少讲道理”的写法,使它在同类参考书中辨识度很高,尤其适合已经能写简单脚本、却对标准库感到庞杂的开发者。 需要提醒的是,本书出版于 2001 年,对应 Python 2.0,今天直接照抄书里的代码多半会报错。它的价值不在于逐条对照模块文档,而在于帮助读者建立“标准库能覆盖哪些事”的全局地图,以及学习如何用示例驱动的方式去查库、试库。对于收藏 O'Reilly 动物书、研究 Python 生态演变,或者想体会早期 Python 社区技术写作风格的读者,这本书仍然有相当的可读性与史料意义;如果只是要解决当下的开发问题,应优先查阅最新的官方文档。

Who it's for

A good fit for

  • 已掌握 Python 基本语法、想系统认识标准库全貌的中级开发者
  • 习惯通过可运行示例而不是长篇说明来学习的程序员
  • 需要一本按主题索引标准库功能的案头参考书的工程师
  • 对 Python 历史与早期社区写作风格感兴趣的读者

Not a good fit for

  • 完全没有编程基础的入门读者,书中不讲解语言语法
  • 只使用 Python 3 做实际项目、需要即查即用代码的开发者
  • 希望获得现代第三方库与工程实践指导的读者

Reading tips

  1. 先通读目录,建立“标准库能做什么”的分类地图,再按项目需要挑选章节精读。
  2. 把书中的示例脚本当作模板,改写到自己的 Python 3 环境中运行,对照差异理解版本演进。
  3. 配合官方文档使用:本书用于了解模块定位与典型用法,接口细节以最新文档为准。
  4. 遇到不熟悉的模块时,先读示例再看注释,最后动手写一个类似用途的小脚本巩固。

Contents

  1. Core modules
  2. More standard modules
  3. Threads and processes
  4. Data representation
  5. File formats
  6. Mail and news message processing
  7. Network protocols
  8. Internationalization
  9. Multimedia modules
  10. Data storage
  11. Tools and utilities
  12. Platform-specific modules
  13. Implementation support modules
  14. Other modules

FAQ

这本书对应哪个 Python 版本?
本书主要覆盖 Python 2.0,示例在 Python 1.5.2 与 2.0 下测试,并声明尽量不依赖内部实现细节,其余 2.x 版本大多可用。书中内容与 Python 3 的标准库存在明显差异。
书中有没有中文译本?
目前公开资料显示,该书由 O'Reilly 于 2001 年出版英文原版,未见由正规出版社出版的中文简体译本;市面上流通的版本多为英文原版或其电子版。
书里的示例代码怎么获取?
原书随书附赠光盘,收录全部示例脚本;O'Reilly 也提供配套示例下载页面,作者本人的网站上有更新说明。如今可在 O'Reilly 平台查阅书中示例相关内容。
它和官方标准库文档有什么区别?
官方文档以接口为单位罗列参数与返回值,本书以问题为单位给出可运行的短示例,按用途组织模块,更接近“怎么用”的速查手册。
现在还值得读吗?
若目标是直接用于当前开发,建议改读最新官方文档;若想了解标准库的整体结构、早期惯用法与 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.

Top rated in the same category