Powerful Python: Patterns and Strategies with Modern Python

Powerful Python: Patterns and Strategies with Modern Python

Powerful Python: Patterns and Strategies with Modern Python
Автор: Maxwell Aaron
Дата выхода: 2025
Издательство: O’Reilly Media, Inc.
Количество страниц: 200
Размер файла: 1,2 МБ
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы

Cover
Copyright
Table of Contents
Preface
Who This Book Is For
The Two Levels of Learning
Our Strategy in This Book
What’s Not Covered
Getting the Most Out of This Book
Conventions Used in This Book
Using Code Examples
O’Reilly Online Learning
How to Contact Us
Acknowledgments
Chapter 1. Scaling with Generators
Iteration in Python
Generator Functions
Advancing next()
Converting to a Generator Function
Do You Need Generators?
Generator Patterns and Scalable Composability
Text Lines to Dicts
Composable Interfaces
Fanning Out
Fanning In
Python Is Filled with Iterators
The Iterator Protocol
Conclusion
Chapter 2. Creating Collections with Comprehensions
List Comprehensions
Formatting for Readability (and More)
Multiple Sources and Filters
Independent Clauses
Multiple Filters
Comprehensions and Generators
Dictionaries, Sets, and Tuples
Conclusion
Chapter 3. Advanced Functions
Accepting and Passing Variable Arguments
Argument Unpacking
Variable Keyword Arguments
Keyword Unpacking
Combining Positional and Keyword Arguments
Functions as Objects
Key Functions in Python
Conclusion
Chapter 4. Decorators
The Basic Decorator
Generic Decorators
Decorating Methods
Data in Decorators
Accessing Inner Data
Nonlocal Decorator State
Decorators That Take Arguments
Class-Based Decorators
Implementing Class-Based Decorators
Benefits of Class-Based Decorators
Decorators for Classes
Conclusion
Chapter 5. Exceptions and Errors
The Basic Idea
Handling Exceptions
Exceptions for Flow Control
Finally Blocks
Dictionary Exceptions
Exceptions Are Objects
Raising Exceptions
Catching and Re-Raising
The Most Diabolical Python Antipattern
Conclusion
Chapter 6. Classes and Objects: Beyond the Basics
Properties
Property Patterns
Validation
Properties and Refactoring
The Factory Patterns
Alternative Constructors: The Simple Factory
Dynamic Type: The Factory Method Pattern
The Observer Pattern
The Simple Observer
A Pythonic Refinement
Several Channels
Magic Methods
Rebelliously Misusing Magic Methods
Conclusion
Chapter 7. Automated Testing
What Is Test-Driven Development?
Unit Tests and Simple Assertions
Fixtures and Common Test Setup
Asserting Exceptions
Using Subtests
Conclusion
Chapter 8. Module Organization
Spawning a Module
Creating Separate Libraries
Multifile Modules
Import Syntax and Version Control
Nested Submodule Structure
Antipattern Warning
Import Side Effects
Conclusion
Chapter 9. Logging in Python
The Basic Interface
Log Levels
Why Do We Have Log Levels?
Configuring the Basic Interface
Passing Arguments
Beyond Basic: Loggers
Log Destinations: Handlers and Streams
Logging to Multiple Destinations
Record Layout with Formatters
Conclusion
Parting Words
Index
About the Author
Colophon

Once you've mastered the basics of Python, how do you skill up to the top 1%? How do you focus your learning time on topics that yield the most benefit for production engineering and data teams—without getting distracted by info of little real-world use? This book answers these questions and more.

Based on author Aaron Maxwell's software engineering career in Silicon Valley, this unique book focuses on the Python first principles that act to accelerate everything else: the 5% of programming knowledge that makes the remaining 95% fall like dominos. It's also this knowledge that helps you become an exceptional Python programmer, fast.

  • Learn how to think like a Pythonista: explore advanced Pythonic thinking

  • Create lists, dicts, and other data structures using a high-level, readable, and maintainable syntax

  • Explore higher-order function abstractions that form the basis of Python libraries

  • Examine Python's metaprogramming tools for priceless patterns of code reuse

  • Master Python's error model and learn how to leverage it in your own code

  • Learn the more potent and advanced tools of Python's object system

  • Take a deep dive into Python's automated testing and TDD

  • Learn how Python logging helps you troubleshoot and debug more quickly


Похожее:

Список отзывов:

Нет отзывов к книге.