Effective Python

125 Specific Ways to Write Better Python

Paperback Engels 2025 3e druk 9780138172183
€ 64,98
Levertijd ± 8 werkdagen
Gratis verzonden

Samenvatting

Master the art of Python programming with 125 actionable best practices to write more efficient, readable, and maintainable code.

Python is a versatile and powerful language, but leveraging its full potential requires more than just knowing the syntax. Effective Python: 125 Specific Ways to Write Better Python, 3rd Edition is your comprehensive guide to mastering Python's unique strengths and avoiding its hidden pitfalls. This updated edition builds on the acclaimed second edition, expanding from 90 to 125 best practices that are essential for writing high-quality Python code.
Drawing on years of experience at Google, Brett Slatkin offers clear, concise, and practical advice for both new and experienced Python developers. Each item in the book provides insight into the "Pythonic" way of programming, helping you understand how to write code that is not only effective but also elegant and maintainable. Whether you're building web applications, analyzing data, writing automation scripts, or training AI models, this book will equip you with the skills to make a significant impact using Python.
Key Features of the 3rd Edition:

-Expanded Content: Now with 125 actionable guidelines, including 35 entirely new items.
-Updated Best Practices: Reflects the latest features in Python releases up to version 3.13.
-New Chapters: Additional chapters on how to build robust programs that achieve high performance.
-Advanced Topics: In-depth coverage of creating C-extension modules and interfacing with native shared libraries.
-Practical Examples: Realistic code examples that illustrate each best practice.

Specificaties

ISBN13:9780138172183
Taal:Engels
Bindwijze:paperback
Aantal pagina's:608
Druk:3
Verschijningsdatum:8-1-2025
Hoofdrubriek:IT-management / ICT

Lezersrecensies

Wees de eerste die een lezersrecensie schrijft!

Inhoudsopgave

Chapter 1: Pythonic Thinking
Item 1: Know Which Version of Python You’re Using
Item 2: Follow the PEP 8 Style Guide
Item 3: Never Expect Python to Detect Errors at Compile Time
Item 4: Write Helper Functions Instead of Complex Expressions
Item 5: Prefer Multiple-Assignment Unpacking Over Indexing
Item 6: Always Surround Single-Element Tuples with Parentheses
Item 7: Consider Conditional Expressions for Simple Inline Logic
Item 8: Prevent Repetition with Assignment Expressions
Item 9: Consider match for Destructuring in Flow Control; Avoid When if Statements Are Sufficient
Chapter 2: Strings and Slicing
Item 10: Know the Differences Between bytes and str
Item 11: Prefer Interpolated F-Strings over C-Style Format Strings and str.format
Item 12: Understand the Difference Between repr and str when Printing Objects
Item 13: Prefer Explicit String Concatenation over Implicit, Especially in Lists
Item 14: Know How to Slice Sequences
Item 15: Avoid Striding and Slicing in a Single Expression
Item 16: Prefer Catch-All Unpacking Over Slicing
Chapter 3: Loops and Iterators
Item 17: Prefer enumerate over range
Item 18: Use zip to Process Iterators in Parallel
Item 19: Avoid else Blocks After for and while Loops
Item 20: Never Use for Loop Variables After the Loop Ends
Item 21: Be Defensive when Iterating over Arguments
Item 22: Never Modify Containers While Iterating over Them; Use Copies or Caches Instead
Item 23: Pass Iterators to any and all for Efficient Short-Circuiting Logic
Item 24: Consider itertools for Working with Iterators and Generators
Chapter 4: Dictionaries
Item 25: Be Cautious when Relying on Dictionary Insertion Ordering
Item 26: Prefer get over in and KeyError to Handle Missing Dictionary Keys
Item 27: Prefer defaultdict over setdefault to Handle Missing Items in Internal State
Item 28: Know How to Construct Key-Dependent Default Values with __missing__
Item 29: Compose Classes Instead of Deeply Nesting Dictionaries, Lists, and Tuples
Chapter 5: Functions
Item 30: Know That Function Arguments Can Be Mutated
Item 31: Return Dedicated Result Objects Instead of Requiring Function Callers to Unpack More Than Three Variables
Item 32: Prefer Raising Exceptions to Returning None
Item 33: Know How Closures Interact with Variable Scope and nonlocal
Item 34: Reduce Visual Noise with Variable Positional Arguments
Item 35: Provide Optional Behavior with Keyword Arguments
Item 36: Use None and Docstrings to Specify Dynamic Default Arguments
Item 37: Enforce Clarity with Keyword-Only and Positional-Only Arguments
Item 38: Define Function Decorators with functools.wraps
Item 39: Prefer functools.partial over lambda Expressions for Glue Functions
Chapter 6: Comprehensions and Generators
Item 40: Use Comprehensions Instead of map and filter
Item 41: Avoid More Than Two Control Subexpressions in Comprehensions
Item 42: Reduce Repetition in Comprehensions with Assignment Expressions
Item 43: Consider Generators Instead of Returning Lists
Item 44: Consider Generator Expressions for Large List Comprehensions
Item 45: Compose Multiple Generators with yield from
Item 46: Pass Iterators into Generators as Arguments Instead of Calling the send Method
Item 47: Manage Iterative State Transitions with a Class Instead of the Generator throw Method
Chapter 7: Classes and Interfaces
Item 48: Accept Functions Instead of Classes for Simple Interfaces
Item 49: Prefer Object-Oriented Polymorphism over Functions with isinstance Checks
Item 50: Consider functools.singledispatch for Functional-Style Programming Instead of Object-Oriented Polymorphism
Item 51: Prefer dataclasses for Defining Lightweight Classes
Item 52: Use @classmethod Polymorphism to Construct Objects Generically
Item 53: Initialize Parent Classes with super
Afgekapt op 60 regels

Managementboek Top 100

€ 64,98
Levertijd ongeveer 8 werkdagen
Gratis verzonden

Rubrieken

Producten

    Auteurs

      Trefwoorden

        Artikelen

          Effective Python