书籍详情
《EffectivePython》[48M]百度网盘|亲测有效|pdf下载
  • EffectivePython

  • 出版社:出版集团图书专营店
  • 出版时间:2020-07
  • 热度:11671
  • 上架时间:2024-06-30 09:38:03
  • 价格:0.0
书籍下载
书籍预览
免责声明

本站支持尊重有效期内的版权/著作权,所有的资源均来自于互联网网友分享或网盘资源,一旦发现资源涉及侵权,将立即删除。希望所有用户一同监督并反馈问题,如有侵权请联系站长或发送邮件到ebook666@outlook.com,本站将立马改正

内容介绍

基本信息

  • 商品名称:Effective Python(改善Python程序的90个建议第2版英文版)/原味精品书系
  • 作者:(美)布雷特·斯莱特金|责编:刘佳禾
  • 定价:128
  • 出版社:电子工业
  • 书号:9787121386930

其他参考信息(以实物为准)

  • 出版时间:2020-07-01
  • 印刷时间:2020-07-01
  • 版次:2
  • 印次:1
  • 开本:16开
  • 包装:平装
  • 页数:444
  • 字数:478千字

内容提要

Brett Slatkin根据自己在Google公司多年开发Python基础架构所积累的经验,揭示了Python语言中一些鲜为人知的微妙特性,并给出了能够改善代码功能及运行效率的习惯用法。书中汇聚了90个 的实践原则、开发技巧和便捷方案,并以实用的代码范例来解释它们。通过本书,你能够了解到解决关键编程任务的实用技巧,并学会编写易于理解、便于维护且利于改进的代码。除此之外,本书第2版基本上修改了 版中的所有条目,以反映Python实践的演变历程。

作者简介

Google首席软件工程师Python实战经验总结,Python 3 实用指南,90条实用原则,编写健壮、高效的代码。 Brett Slaktin,Google首席软件工程师、Google消费者调查项目工程主管及联合创始人、PubSubHubbub 协议联合创始人。他启动了Google 个云计算产品App Engine。十四年前,他在实习时使用Python管理了Google大量的服务器。
  在日常工作之余,他喜欢弹钢琴和冲浪。他也喜欢在自己的网站上发布一些编程相关的话题和文章。他拥有纽约市哥伦比亚大学计算机工程学士学位。现居旧金山。

目录

Chapter 1 Pythonic Thinking 1
Item 1: Know Which Version of Python You’re Using 1
Item 2: Follow the PEP 8 Style Guide 2
Item 3: Know the Differences Between bytes and str 5
Item 4: Prefer Interpolated F-Strings Over C-style
Format Strings and str.format 11
Item 5: Write Helper Functions Instead of
Complex Expressions 21
Item 6: Prefer Multiple Assignment Unpacking
Over Indexing 24
Item 7: Prefer enumerate Over range 28
Item 8: Use zip to Process Iterators in Parallel 30
Item 9: Avoid else Blocks After for and while Loops 32
Item 10: Prevent Repetition with Assignment Expressions 35
Chapter 2 Lists and Dictionaries 43
Item 11: Know How to Slice Sequences 43
Item 12: Avoid Striding and Slicing in a Single Expression 46
Item 13: Prefer Catch-All Unpacking Over Slicing 48
Item 14: Sort by Complex Criteria Using the key Parameter 52
Item 15: Be Cautious When Relying on dict
Insertion Ordering 58
Item 16: Prefer get Over in and KeyError to
Handle Missing Dictionary Keys 65
Item 17: Prefer defaultdict Over setdefault to
Handle Missing Items in Internal State 70
Item 18: Know How to Construct Key-Dependent
Default Values with __missing__ 73
Chapter 3 Functions 77
Item 19: Never Unpack More Than Three Variables
When Functions Return Multiple Values 77
Item 20: Prefer Raising Exceptions to Returning None 80
Item 21: Know How Closures Interact with Variable Scope 83
Item 22: Reduce Visual Noise with Variable
Positional Arguments 87
Item 23: Provide Optional Behavior with Keyword Arguments 90
Item 24: Use None and Docstrings to Specify
Dynamic Default Arguments 94
Item 25: Enforce Clarity with Keyword-Only and
Positional-Only Arguments 97
Item 26: Define Function Decorators with functools.wraps 102
Chapter 4 Comprehensions and Generators 107
Item 27: Use Comprehensions Instead of map and filter 107
Item 28: Avoid More Than Two Control Subexpressions in
Comprehensions 109
Item 29: Avoid Repeated Work in Comprehensions by Using
Assignment Expressions 111
Item 30: Consider Generators Instead of Returning Lists 114
Item 31: Be Defensive When Iterating Over Arguments 117
Item 32: Consider Generator Expressions for Large List
Comprehensions 122
Item 33: Compose Multiple Generators with yield from 124
Item 34: Avoid Injecting Data into Generators with send 127
Item 35: Avoid Causing State Transitions in
Generators with throw 133
Item 36: Consider itertools for Working with Iterators
and Generators 138
Chapter 5 Classes and Interfaces 145
Item 37: Compose Classes Instead of Nesting
Many Levels of Built-in Types 145
Item 38: Accept Functions Instead of Classes for
Simple Interfaces 152
Item 39: Use @classmethod Polymorphism to
Construct Objects Generically 155
Item 40: Initialize Parent Classes with super 160
Item 41: Consider Composing Functionality
with Mix-in Classes 165
Item 42: Prefer Public Attributes Over Private Ones 170
Item 43: Inherit from collections.abc for
Custom Container Types 175
Chapter 6 Metaclasses and Attributes 181
Item 44: Use Plain Attributes Instead of Setter and
Getter Methods 181
Item 45: Consider @property Instead of
Refactoring Attributes 186
Item 46: Use Descriptors for Reusable @property Methods 190
Item 47: Use __getattr__, __getattribute__, and
__setattr__ for Lazy Attributes 195
Item 48: Validate Subclasses with __init_subclass__ 201
Item 49: Register Class Existence with __init_subclass__ 208
Item 50: Annotate Class Attributes with __set_name__ 214
Item 51: Prefer Class Decorators Over Metaclasses for
Composable Class Extensions 218
Chapter 7 Concurrency and Parallelism 225
Item 52: Use subprocess to Manage Child Processes 226
Item 53: Use Threads for Blocking I/O, Avoid for Parallelism 230
Item 54: Use Lock to Prevent Data Races in Threads 235
Item 55: Use Queue to Coordinate Work Between Threads 238
Item 56: Know How to Recognize When Concurrency
Is Necessary 248
Item 57: Avoid Creating New Thread Instances for
On-demand Fan-out 252
Item 58: Understand How Using Queue for
Concurrency Requires Refactoring 257
Item 59: Consider ThreadPoolExecutor When Threads
Are Necessary for C