| 000 | 00000cam u2200205 a 4500 | |
| 001 | 000045965709 | |
| 005 | 20181227144009 | |
| 008 | 181224s2015 nju 001 0 eng d | |
| 010 | ▼a 2014048305 | |
| 020 | ▼a 9780134034287 (pbk. : alk. paper) | |
| 020 | ▼a 0134034287 (pbk. : alk. paper) | |
| 035 | ▼a (KERIS)REF000017625878 | |
| 040 | ▼a DLC ▼b eng ▼c DLC ▼e rda ▼d DLC ▼d 211009 | |
| 050 | 0 0 | ▼a QA76.73.P98 ▼b S57 2015 |
| 082 | 0 0 | ▼a 005.13/3 ▼2 23 |
| 084 | ▼a 005.133 ▼2 DDCK | |
| 090 | ▼a 005.133 ▼b S6312e | |
| 100 | 1 | ▼a Slatkin, Brett. |
| 245 | 1 0 | ▼a Effective Python : ▼b 59 specific ways to write better Python / ▼c Brett Slatkin. |
| 260 | ▼a Upper Saddle River, NJ : ▼b Addison-Wesley, ▼c c2015. | |
| 300 | ▼a xviii, 227 p. : ; ▼c 24 cm. | |
| 500 | ▼a Includes index. | |
| 650 | 0 | ▼a Python (Computer program language). |
| 650 | 0 | ▼a Computer programming. |
| 945 | ▼a KLPA |
소장정보
| No. | 소장처 | 청구기호 | 등록번호 | 도서상태 | 반납예정일 | 예약 | 서비스 |
|---|---|---|---|---|---|---|---|
| No. 1 | 소장처 중앙도서관/서고6층/ | 청구기호 005.133 S6312e | 등록번호 111801251 (3회 대출) | 도서상태 대출가능 | 반납예정일 | 예약 | 서비스 |
컨텐츠정보
책소개
“Each item in Slatkin’s Effective Python teaches a self-contained lesson with its own source code. This makes the book random-access: Items are easy to browse and study in whatever order the reader needs. I will be recommending Effective Python to students as an admirably compact source of mainstream advice on a very broad range of topics for the intermediate Python programmer.”
—Brandon Rhodes, software engineer at Dropbox and chair of PyCon 2016-2017
It’s easy to start coding with Python, which is why the language is so popular. However, Python’s unique strengths, charms, and expressiveness can be hard to grasp, and there are hidden pitfalls that can easily trip you up.
Effective Python will help you master a truly “Pythonic” approach to programming, harnessing Python’s full power to write exceptionally robust and well-performing code. Using the concise, scenario-driven style pioneered in Scott Meyers’ best-selling Effective C++, Brett Slatkin brings together 59 Python best practices, tips, and shortcuts, and explains them with realistic code examples.
Drawing on years of experience building Python infrastructure at Google, Slatkin uncovers little-known quirks and idioms that powerfully impact code behavior and performance. You’ll learn the best way to accomplish key tasks, so you can write code that’s easier to understand, maintain, and improve.
Key features include
- Actionable guidelines for all major areas of Python 3.x and 2.x development, with detailed explanations and examples
- Best practices for writing functions that clarify intention, promote reuse, and avoid bugs
- Coverage of how to accurately express behaviors with classes and objects
- Guidance on how to avoid pitfalls with metaclasses and dynamic attributes
- More efficient approaches to concurrency and parallelism
- Better techniques and idioms for using Python’s built-in modules
- Tools and best practices for collaborative development
- Solutions for debugging, testing, and optimization in order to improve quality and performance
Offers best practices for writing well-performing code using Python, including writing functions that clarify intention, promote reuse, and avoid bugs; efficient approaches to concurrency and parallelism; and tools for collaborative development.
정보제공 :
목차
Preface p. xiii Acknowledgments p. xvii About the Author p. xix Chapter 1 Pythonic Thinking p. 1 Item 1 Know Which Version of Python You''re Using p. 1 Item 2 Follow the PEP 8 Style Guide p. 2 Item 3 Know the Differences Between bytes, str, and unicode p. 5 Item 4 Write Helper Functions Instead of Complex Expressions p. 8 Item 5 Know How to Slice Sequences p. 10 Item 6 Avoid Using start, end, and stride in a Single Slice p. 13 Item 7 Use List Comprehensions Instead of map and filter p. 15 Item 8 Avoid More Than Two Expressions in List Comprehensions p. 16 Item 9 Consider Generator Expressions for Large Comprehensions p. 18 Item 10 Prefer enumerate Over range p. 20 Item 11 Use zip to Process Iterators in Parallel p. 21 Item 12 Avoid else Blocks After for and while Loops p. 23 Item 13 Take Advantage of Each Block in try/except/else/finally p. 26 Chapter 2 Functions p. 29 Item 14 Prefer Exceptions to Returning None p. 29 Item 15 Know How Closures Interact with Variable Scope p. 31 Item 16 Consider Generators Instead of Returning Lists p. 36 Item 17 Be Defensive When Iterating Over Arguments p. 38 Item 18 Reduce Visual Noise with Variable Positional Arguments p. 43 Item 19 Provide Optional Behavior with Keyword Arguments p. 45 Item 20 Use None and Docstrings to Specify Dynamic Default Arguments p. 48 Item 21 Enforce Clarity with Keyword-Only Arguments p. 51 Chapter 3 Classes and Inheritance p. 55 Item 22 Prefer Helper Classes Over Bookkeeping with Dictionaries and Tuples p. 55 Item 23 Accept Functions for Simple Interfaces Instead of Classes p. 61 Item 24 Use @classmethod Polymorphism to Construct Objects Generically p. 64 Item 25 Initialize Parent Classes with super p. 69 Item 26 Use Multiple Inheritance Only for Mix-in Utility Classes p. 73 Item 27 Prefer Public Attributes Over Private Ones p. 78 Item 28 Inherit from collections.abc for Custom Container Types p. 83 Chapter 4 Metaclasses and Attributes p. 87 Item 29 Use Plain Attributes Instead of Get and Set Methods p. 87 Item 30 Consider @property Instead of Refactoring Attributes p. 91 Item 31 Use Descriptors for Reusable @property Methods p. 95 Item 32 Use getattr, getattribute, and setattr for Lazy Attributes p. 100 Item 33 Validate Subclasses with Metaclasses p. 105 Item 34 Register Class Existence with Metaclasses p. 108 Item 35 Annotate Class Attributes with Metaclasses p. 112 Chapter 5 Concurrency and Parallelism p. 117 Item 36 Use subprocess to Manage Child Processes p. 118 Item 37 Use Threads for Blocking I/O, Avoid for Parallelism p. 122 Item 38 Use Lock to Prevent Data Races in Threads p. 126 Item 39 Use Queue to Coordinate Work Between Threads p. 129 Item 40 Consider Coroutines to Run Many Functions Concurrently p. 136 Item 41 Consider concurrent, futures for True Parallelism p. 145 Chapter 6 Built-in Modules p. 151 Item 42 Define Function Decorators with functools.wraps p. 151 Item 43 Consider contextlib and with Statements for Reusable try/finally Behavior p. 153 Item 44 Make pickle Reliable with copyreg p. 157 Item 45 Use datetime Instead of time for Local Clocks p. 162 Item 46 Use Built-in Algorithms and Data Structures p. 166 Item 47 Use decimal When Precision Is Paramount p. 171 Item 48 Know Where to Find Community-Built Modules p. 173 Chapter 7 Collaboration p. 175 Item 49 Write Docstrings for Every Function, Class, and Module p. 175 Item 50 Use Packages to Organize Modules and Provide Stable APIs p. 179 Item 51 Define a Root Exception to Insulate Callers from APIs p. 184 Item 52 Know How to Break Circular Dependencies p. 187 Item 53 Use Virtual Environments for Isolated and Reproducible Dependencies p. 192 Chapter 8 Production p. 199 Item 54 Consider Module-Scoped Code to Configure Deployment Environments p. 199 Item 55 Use repr Strings for Debugging Output p. 202 Item 56 Test Everything with unittest p. 204 Item 57 Consider Interactive Debugging with pdb p. 208 Item 58 Profile Before Optimizing p. 209 Item 59 Use tracemalloc to Understand Memory Usage and Leaks p. 214 Index p. 217
