幫助中心 | 我的帳號 | 關於我們

Effective Python(改善Python程序的90個建議第2版英文版)/原味精品書系

  • 作者:(美)布雷特·斯萊特金|責編:劉佳禾
  • 出版社:電子工業
  • ISBN:9787121386930
  • 出版日期:2020/07/01
  • 裝幀:平裝
  • 頁數:444
人民幣:RMB 128 元      售價:
放入購物車
加入收藏夾

內容大鋼
    Brett Slatkin根據自己在Google公司多年開發Python基礎架構所積累的經驗,揭示了Python語言中一些鮮為人知的微妙特性,並給出了能夠改善代碼功能及運行效率的習慣用法。書中匯聚了90個優秀的實踐原則、開發技巧和便捷方案,並以實用的代碼範例來解釋它們。通過本書,你能夠了解到解決關鍵編程任務的實用技巧,並學會編寫易於理解、便於維護且利於改進的代碼。除此之外,本書第2版基本上修改了第1版中的所有條目,以反映Python實踐的演變歷程。

作者介紹
(美)布雷特·斯萊特金|責編:劉佳禾
    布雷特·斯萊特金(Brett Slatkin),Google首席軟體工程師、Google消費者調查項目工程主管及聯合創始人、PubSubHubbub協議聯合創始人。他啟動了Google第一個雲計算產品App Engine。     十四年前,他在實習時使用Python管理了Google大量的伺服器。     在日常工作之餘,他喜歡彈鋼琴和衝浪。他也喜歡在自己的網站上發布一些編程相關的話題和文章。他擁有紐約市哥倫比亞大學電腦工程學士學位。現居舊金山。

目錄
Chapter 1  Pythonic Thinking
  Item 1:Know Which Version of Python You're Using
  ltem 2:Follow the PEP 8 Style Guide
  Item 3:Know the Differences Between bytes and str
  Item 4:Prefer Interpolated F-Strings Over C-style Format Strings and str.format
  Item 5:Write Helper Functions Instead of Complex Expressions
  Item 6:Prefer Multiple Assignment Unpacking Over Indexing
  Item 7:Prefer enumerate Over range
  Item 8:Use zip to Process Iterators in Parallel
  ltem 9:Avoid else Blocks After for and while Loops
  Item 10:Prevent Repetition with Assignment Expressions
Chapter 2  Lists and Dictionaries
  Item 11:Know How to Slice Sequences
  Item 12: Avoid striding and slicingin a Single Expression
  Item 13:Prefer Catch-All Unpacking Over Slicing
  Item 14: Sort by Complex criteria Usingthe kevParameter
  Item 15:Be Cautious When Relying on dict Insertion Ordering
  Item 16:Prefer get Over in and KeyError to Handle Missing Dictionary Keys
  Item 17:Prefer defaultdict Over setdefalt to Handle Missing Items in Internal State
  Item 18:Know How to Construct Key-Dependent Default Values with _missing
Chapter 3  Functions
  Item 19:Never Unpack More Than Three Variables When Functions Return Multiple Values
  Item 20:Prefer Raising Exceptions to Returning None
  Item 21:Know How Closures Interact with Variable Scope
  Item 22:Reduce Visual Noise with Variable Positional Arguments
  Item 23:Provide Optional Behavior with Keyword Arguments
  Item 24:Use None and Docstrings to Specify Dynamic Default Arguments
  Item 25:Enforce Clarity with Keyword-Only and Positional-Only Arguments
  Item 26:Define Function Decorators with functools.wraps
Chapter 4  Comprehensions and Generators
  Item 27:Use Comprehensions Instead of map and filter
  Item 28:Avoid More Than Two Control Subexpressions in Comprehensions
  Item 29:Avoid Repeated Work in Comprehensions by Using Assignment Expressions
  Item 30:Consider Generators Instead of Returning Lists
  Item 31:Be Defensive When Iterating Over Arguments
  Item 32:Consider Generator Expressions for Large List Comprehensions
  Item 33:Compose Multiple Generators with yield from
  Item 34:Avoid Injecting Data into Generators with send
  Item 35: Avoid Causing State Transitions in Generators with throw
  Item s6: consder itertools for Working with iterators and Generators
Chapter 5  Classes and Interfaces.
  Item 37:Compose Classes Instead of Nesting Many Levels of Built-in Types
  Item 38:Accept Functions Instead of Classes for Simple Interfaces
  Item 39:Use aclassmethod Polymorphism to Construct Objects Genericaly
  Item 40:Initialize Parent Classes with super
  Item 41:Consider Composing Functionality with Mix-in Classes
  Item 42:Prefer Public Atributes Over Private Ones
  Item 43:Inherit from collections.abc for Custom Container Types
Chapter 6  Metaclasses and Attributes
  Item 44:Use Plain Attributes Instead of Setter and Getter Methods

  Item 45:Consider aproperty Instead of Refactoring Attributes
  Item 46:Use Descriptors for Reusable aproperty Methods
  Item 47:Use__getattr__,__getattribute,and-setattrfor Lazy Attributes
  Item 48:Validate Subclasses with__init_subclass__
  Item 49:Register Class Existence with__init_subclass__
  Item 50:Annotate Class Attributes with__set_name__
  Item 51:Prefer Class Decorators Over Metaclasses for Composable Class Extensions
Chapter 7  Concurrency and Parallelism
  Item 52:Use subprocess to Manage Child Processes
  Item 53:Use Threads for Blocking I/O,Avoid for Parallelism
  Item 54:Use Lock to Prevent Data Races in Threads
  Item 55:Use Queue to Coordinate Work Between Threads
  Item 56:Know How to Recognize When Concurrency Is Necessary
  Item 57:Avoid Creating New Thread Instances for On-demand Fan-out
  Item 58:Understand How Using Queue for Concurrency Requires Refactoring
  Item 59:Consider ThreadPoolExecutor When Threads Are Necessary for Concurrency
  Item 60:Achieve Highly Concurrent I/O with Coroutines
  Item 61:Know How to Port Threaded I/O to asyncio
  Item 62:Mix Threads and Coroutines to Ease the Transition to asyncio
  Item 63:Avoid Blocking the asyncio Event Loop to Maximize Responsiveness
  Item 64:Consider concurrent.futures for True Parallelism
Chapter 8  Robustness and Performance
  Item 65:Take Advantage of Each Block in try/except/else/finally
  Item 66:Consider contextlib and with Statements for Reusable try/finally Behavior
  Item 67:Use datetime Instead of time for Local Clocks
  Item 68:Make pickle Reliable with copyreg
  Item 69:Use decimal When Precision Is Paramount
  Item 70:Profile Before Optimizing
  Item 71:Prefer deque for Producer-Consumer Queues
  Item 72:Consider Searching Sorted Sequences with bisect
  Item 73:Know How to Use heapq for Priority Queues
  Item 74:Consider memoryview and bytearray for Zero-Copy Interactions with bytes
Chapter 9  Testing and Debugging
  Item 75:Use repr Strings for Debugging Output
  Item 76:Verify Related Behaviors in TestCase Subclasses
  Item 77:Isolate Tests from ach Other with setUp, tearDown,setUpModule,and tearDownModule
  Item 78:Use Mocks to Test Code with Complex Dependencies
  Item 79:Encapsulate Dependencies to Facilitate Mocking and Testing
  Item 80:Consider !nteractive Debugging with pdk
  Item 81:Use tracemalloc to Understand Memory Usage and Leaks
Chapter 10  Collaboration
  Item 82:Know.Where te Find Community-Built Modules
  Item 83:Use Virtual Environments for Isolated and Reproducible Dependencies
  Item 84:Write Docstrings for Every Function, Class,and Module
  Item 85:Use Packages to Organize Modules and Provide Stable APls
  Item 86:Consider Module-Scoped Code to Configure Deployment Environments
  Item 87:Define a Root Exception to Insulate Callers from APIs
  Item 88:Know How to Break Circular Dependencies
  Item 89:Consider warnings to Refactor and Migrate Usage
  Item 90:Consider Static Analysis via typing to Obviate Bugs

Index

  • 商品搜索:
  • | 高級搜索
首頁新手上路客服中心關於我們聯絡我們Top↑
Copyrightc 1999~2008 美商天龍國際圖書股份有限公司 臺灣分公司. All rights reserved.
營業地址:臺北市中正區重慶南路一段103號1F 105號1F-2F
讀者服務部電話:02-2381-2033 02-2381-1863 時間:週一-週五 10:00-17:00
 服務信箱:bookuu@69book.com 客戶、意見信箱:cs@69book.com
ICP證:浙B2-20060032