Robust Python.
Clasificación: | Libro Electrónico |
---|---|
Autor principal: | |
Formato: | Electrónico eBook |
Idioma: | Inglés |
Publicado: |
Sebastopol :
O'Reilly Media, Incorporated,
2021.
|
Temas: | |
Acceso en línea: | Texto completo (Requiere registro previo con correo institucional) |
Tabla de Contenidos:
- Intro
- Copyright
- Table of Contents
- Preface
- Who Should Read This Book
- About This Book
- Conventions Used in This Book
- Using Code Examples
- O'Reilly Online Learning
- How to Contact Us
- Acknowledgments
- Chapter 1. Introduction to Robust Python
- Robustness
- Why Does Robustness Matter?
- What's Your Intent?
- Asynchronous Communication
- Examples of Intent in Python
- Collections
- Iteration
- Law of Least Surprise
- Closing Thoughts
- Part I. Annotating Your Code with Types
- Chapter 2. Introduction to Python Types
- What's in a Type?
- Mechanical Representation
- Semantic Representation
- Typing Systems
- Strong Versus Weak
- Dynamic Versus Static
- Duck Typing
- Closing Thoughts
- Chapter 3. Type Annotations
- What Are Type Annotations?
- Benefits of Type Annotations
- Autocomplete
- Typecheckers
- Exercise: Spot the Bug
- When to Use Type Annotations
- Closing Thoughts
- Chapter 4. Constraining Types
- Optional Type
- Union Types
- Product and Sum Types
- Literal Types
- Annotated Types
- NewType
- Final Types
- Closing Thoughts
- Chapter 5. Collection Types
- Annotating Collections
- Homogeneous Versus Heterogeneous Collections
- TypedDict
- Creating New Collections
- Generics
- Modifying Existing Types
- As Easy as ABC
- Closing Thoughts
- Chapter 6. Customizing Your Typechecker
- Configuring Your Typechecker
- Configuring mypy
- Mypy Reporting
- Speeding Up mypy
- Alternative Typecheckers
- Pyre
- Pyright
- Closing Thoughts
- Chapter 7. Adopting Typechecking Practically
- Trade-offs
- Breaking Even Earlier
- Find Your Pain Points
- Target Code Strategically
- Lean on Your Tooling
- Closing Thoughts
- Part II. Defining Your Own Types
- Chapter 8. User-Defined Types: Enums
- User-Defined Types
- Enumerations
- Enum
- When Not to Use
- Advanced Usage
- Automatic Values
- Flags
- Integer Conversion
- Unique
- Closing Thoughts
- Chapter 9. User-Defined Types: Data Classes
- Data Classes in Action
- Usage
- String Conversion
- Equality
- Relational Comparison
- Immutability
- Comparison to Other Types
- Data Classes Versus Dictionaries
- Data Classes Versus TypedDict
- Data Classes Versus namedtuple
- Closing Thoughts
- Chapter 10. User-Defined Types: Classes
- Class Anatomy
- Constructors
- Invariants
- Avoiding Broken Invariants
- Why Are Invariants Beneficial?
- Communicating Invariants
- Consuming Your Class
- What About Maintainers?
- Encapsulation and Maintaining Invariants
- Encapsul-what, Now?
- Protecting Data Access
- Operations
- Closing Thoughts
- Chapter 11. Defining Your Interfaces
- Natural Interface Design
- Thinking Like a User
- Natural Interactions
- Natural Interfaces in Action
- Magic Methods
- Context Managers
- Closing Thoughts
- Chapter 12. Subtyping
- Inheritance
- Substitutability
- Design Considerations
- Composition
- Closing Thoughts