Book Description
Python’s simplicity lets you become productive quickly, but this often means you aren’t using everything it has to offer. With this hands-on guide, you’ll learn how to write effective, idiomatic Python code by leveraging its best—and possibly most neglected—features. Author Luciano Ramalho takes you through Python’s core language features and libraries, and shows you how to make your code shorter, faster, and more readable at the same time.
Many experienced programmers try to bend Python to fit patterns they learned from other languages, and never discover Python features outside of their experience. With this book, those Python programmers will thoroughly learn how to become proficient in Python 3.
This book covers:
- Python data model: understand how special methods are the key to the consistent behavior of objects
- Data structures: take full advantage of built-in types, and understand the text vs bytes duality in the Unicode age
- Functions as objects: view Python functions as first-class objects, and understand how this affects popular design patterns
- Object-oriented idioms: build classes by learning about references, mutability, interfaces, operator overloading, and multiple inheritance
- Control flow: leverage context managers, generators, coroutines, and concurrency with the concurrent.futures and asyncio packages
- Metaprogramming: understand how properties, attribute descriptors, class decorators, and metaclasses work
Table of Contents
Part I. Prologue
Chapter 1. The Python Data Model
Part II. Data structures
Chapter 2. An array of sequences
Chapter 3. Dictionaries and sets
Chapter 4. Text versus bytes
Part III. Functions as objects
Chapter 5. First-class functions
Chapter 6. Design patterns with first-class functions
Chapter 7. Function decorators and closures
Part IV. Object Oriented Idioms
Chapter 8. Object references, mutability and recycling
Chapter 9. A Pythonic object
Chapter 10. Sequence hacking, hashing and slicing
Chapter 11. Interfaces: from protocols to ABCs
Chapter 12. Inheritance: for good or for worse
Chapter 13. Operator overloading: doing it right
Part V. Control flow
Chapter 14. Iterables, iterators and generators
Chapter 15. Context managers and else blocks
Chapter 16. Coroutines
Chapter 17. Concurrency with futures
Chapter 18. Concurrency with asyncio
Part VI. Metaprogramming
Chapter 19. Dynamic attributes and properties
Chapter 20. Attribute descriptors
Chapter 21. Class metaprogramming
Appendix A. Support scripts
中文:
书名:Fluent Python
Python的简单性使您可以快速提高工作效率,但这通常意味着您没有使用它提供的所有功能。通过本实践指南,您将学习如何通过利用其最好的–也可能是最容易被忽视的–特性来编写高效、惯用的Python代码。作者Luciano Ramalho向您介绍了Python的核心语言特性和库,并向您展示了如何使代码更短、更快,同时更具可读性。
许多有经验的程序员试图修改Python以适应他们从其他语言中学到的模式,并且永远不会发现他们经验之外的Python特性。有了这本书,那些Python程序员将彻底学习如何精通Python3。
This book covers:
- Python data model: 了解特殊方法是保持对象行为一致的关键
- Data structures: 充分利用内置类型,理解Unicode时代的文本与字节的二元性
- Functions as objects: 将Python函数视为一流对象,并了解这对流行的设计模式有何影响
- Object-oriented idioms: 通过学习引用、可变性、接口、运算符重载和多重继承来构建类
- Control flow: 利用上下文管理器、生成器、协程和并发与并发。未来和异步包
- Metaprogramming: 了解属性、属性描述符、类修饰符和元类的工作原理
Table of Contents
Part I. Prologue
Chapter 1. The Python Data Model
Part II. Data structures
Chapter 2. An array of sequences
Chapter 3. Dictionaries and sets
第4章.文本与字节
第三部分:作为客体
Chapter 5. First-class functions
Chapter 6. Design patterns with first-class functions
第七章函数装饰器和闭包
第四部分:面向对象的习语
第八章对象引用、可变性和回收
第9章:一个毕德学派的客体
第10章:序列黑客、哈希和切片
第11章:接口:从协议到ABC
第十二章继承:无论是好是坏
第13章.运营者超载:正确操作
Part V. Control flow
第14章:迭代、迭代器和生成器
第15章.上下文管理器和Else块
Chapter 16. Coroutines
第17章:期货交易的并发性
第18章.与Ayncio的并发
Part VI. Metaprogramming
Chapter 19. Dynamic attributes and properties
第20章.属性描述符
Chapter 21. Class metaprogramming
附录A.支持脚本
评论前必须登录!
注册