Table of contents : Table of Contents Introduction Who This Book Is For What This Book Covers How This Book Is Structured What You Need to Use This Book Conventions Errata p2p.wrox.com Part I: Functions Chapter 1: Decorators Understanding Decorators Decorator Syntax Where Decorators Are Used Why You Should Write Decorators When You Should Write Decorators Writing Decorators Decorating Classes Type Switching Summary Chapter 2: Context Managers What Is a Context Manager? Context Manager Syntax When You Should Write Context Managers A Simpler Syntax Summary Chapter 3: Generators. Understanding What a Generator IsUnderstanding Generator Syntax Communication with Generators Iterables Versus Iterators Generators in the Standard Library When to Write Generators When Are Generators Singletons? Generators within Generators Summary Part II: Classes Chapter 4: Magic Methods Magic Method Syntax Available Methods Other Magic Methods Summary Chapter 5: Metaclasses Classes and Objects Writing Metaclasses Using Metaclasses When to Use Metaclasses The Question of Explicit Opt-In Meta-Coding Summary Chapter 6: Class Factories A Review of type. Understanding a Class Factory FunctionDetermining When You Should Write Class Factories Summary Chapter 7: Abstract Base Classes Using Abstract Base Classes Declaring a Virtual Subclass Declaring a Protocol Built-in Abstract Base Classes Summary Part III: Data Chapter 8: Strings and Unicode Text String Versus Byte String Strings with Non-ASCII Characters Other Encodings Reading Files Reading Other Sources Specifying Python File Encodings Strict Codecs Summary Chapter 9: Regular Expressions Why Use Regular Expressions? Regular Expressions in Python. Basic Regular ExpressionsGrouping Lookahead Flags Substitution Compiled Regular Expressions Summary Part IV: Everything Else Chapter 10: Python 2 Versus Python 3 Cross-Compatibility Strategies Changes in Python 3 Standard Library Relocations Version Detection Summary Chapter 11: Unit Testing The Testing Continuum Testing Code Unit Testing Frameworks Mocking Other Testing Tools Summary Chapter 12: CLI Tools OPTPARSE ARGPARSE Summary Chapter 13: asyncio The Event Loop Coroutines Futures and Tasks Callbacks Task Aggregation Queues Servers Summary. Chapter 14: StylePrinciples Standards Summary End User License Agreement.