Skip to product information
Python for Professionals
Python for Professionals
Description
Book Introduction
Programming techniques that unleash Python's potential

Don't force patterns you've learned from other languages ​​into Python.
Python's simplicity can quickly increase your productivity, but that simplicity can also prevent you from fully utilizing the language's rich features.
Learn how to use Python more efficiently and skillfully with this latest revised edition that combines theory and practice.
This book delves deeply into the practical issues you face, and contains only the essential information.
It provides a detailed guide to Python's core features and libraries, and suggests ways to write shorter, faster, and more readable code.
  • You can preview some of the book's contents.
    Preview

index
[PART 1 Data Structures]

CHAPTER 1: The Python Data Model

_1.1 Changes in this chapter
_1.2 A deck of Python Down cards
_1.3 Uses of special methods
_1.4 Special Methods Overview
_1.5 Why len( ) wasn't made into a method
_1.6 Summary

CHAPTER 2 Arrays of Sequences

_2.1 Changes in this chapter
_2.2 Built-in Sequence Overview
_2.3 Comprehensive list and generator expressions
_2.4 Tuples that go beyond immutable lists
_2.5 Unpacking sequences and iterative objects
_2.6 Pattern Matching Using Sequences
_2.7 Slicing
_2.8 Using addition and multiplication operators on sequences
_2.9 list.sort( ) and sorted( ) built-in functions
_2.10 When the list is not the answer
_2.11 Summary

CHAPTER 3 Dictionaries and Sets

_3.1 Changes in this chapter
_3.2 Latest dict syntax
_3.3 Pattern Matching Using Mapping
_3.4 Standard API for mapping types
_3.5 Automatic handling of non-existent keys
_3.6 Variants of dict
_3.7 Immutable Mapping
_3.8 Dictionary View
_3.9 Impact of dict operation
_3.10 Set Theory
_3.11 The impact of how sets work
_3.12 Set operations on dict views
_3.13 Summary

CHAPTER 4 Unicode Text and Bytes

_4.1 Changes in this chapter
_4.2 Text Problems
_4.3 Byte Basic Knowledge
_4.4 Basic Encoder/Decoder
_4.5 Understanding Encoding/Decoding Issues
_4.6 Handling Text Files
_4.7 Comparing properly with Unicode normalization
_4.8 Sorting Unicode Text
_4.9 Unicode Database
_4.10 Dual-Mode str and bytes APIs
_4.11 Summary

CHAPTER 5 Data Class Builder

_5.1 Changes in this chapter
_5.2 Data Class Builder Overview
_5.3 Classic named tuples
_5.4 Tuples with specified data types and item names
_5.5 Basic knowledge of data type hints
_5.6 @dataclass additional explanation
_5.7 Data Classes as Code Smells
_5.8 Class Instance Pattern Matching
_5.9 Summary

CHAPTER 6 Object References, Mutability, and Recycling

_6.1 Changes in this chapter
_6.2 Variable Concept
_6.3 Identity, Homogeneity, and Aliases
_6.4 The default copy is a shallow copy
_6.5 Function parameters as references
_6.6 del and garbage collection
_6.7 Python's Secret to Playing with Immutable Types
_6.8 Summary

[PART 2: Functions as Objects]

CHAPTER 7 Functions as First-Class Objects

_7.1 Changes in this chapter
_7.2 Treating functions as objects
_7.3 High-level functions
_7.4 Anonymous functions
_7.5 Nine Callable Objects
_7.6 User-defined callable types
_7.7 From positional parameters to keyword-only parameters
_7.8 Packages for functional programming
_7.9 Summary

CHAPTER 8 Data Type Hints in Functions

_8.1 Changes in this chapter
_8.2 Gradual Typing Overview
_8.3 Gradual Typing Example
_8.4 Data types defined by supported operations
_8.5 Data types that can be used in annotations
_8.6 Annotations for positional and variable parameters
_8.7 Imperfect Typing and Robust Testing
_8.8 Summary

CHAPTER 9 Decorators and Closures

_9.1 Changes in this chapter
_9.2 Basic knowledge of decorators
_9.3 When Python Executes a Decorator
_9.4 Registration Decorator
_9.5 Variable Scope Rules
_9.6 Closure
_9.7 Nonlocal Declaration
_9.8 Implementing a Simple Decorator
_9.9 Decorators provided by the standard library
_9.10 Parameterized Decorators
_9.11 Summary

CHAPTER 10 First-Class Function Design Patterns

_10.1 Changes in this chapter
_10.2 Case Study: Refactoring Strategies
_10.3 Command Patterns
_10.4 Summary

[PART 3 Classes and Protocols]

CHAPTER 11 Pythonic Objects

_11.1 Changes in this chapter
_11.2 Object Representation
_11.3 The Resurrection of the Vector Class
_11.4 Alternative Constructor
_11.5 @classmethod and @staticmethod
_11.6 Formatted Output
_11.7 Hashable Vector2d
_11.8 Location pattern matching support
_11.9 Vector2d Version #3: Full Code
_11.10 Private and Protected Properties in Python
_11.11 Saving memory with __slots__
_11.12 Overriding Class Properties
_11.13 Summary

CHAPTER 12 SEQUENCE SPECIAL METHODS

_12.1 Changes in this chapter
_12.2 Vector: User-defined sequence type
_12.3 Vector version #1: Vector2d compatible
_12.4 Protocols and Duck Typing
_12.5 Vector Version #2: Slicable Sequences
_12.6 Vector Version #3: Dynamic Property Access
_12.7 Vector Version #4: Hashing and Faster ==
_12.8 Vector Version #5: Formatting
_12.9 Summary

CHAPTER 13 Interfaces, Protocols, and Abstract Base Classes

_13.1 Typing Classification
_13.2 Changes in this chapter
_13.3 Two Protocols
_13.4 Duck Typing
_13.5 Goose Typing
_13.6 Static Protocol
_13.7 Summary

CHAPTER 14 Inheritance: Pros and Cons

_14.1 Changes in this chapter
_14.2 super( ) function
_14.3 Problems with Built-in Inheritance
_14.4 Multiple inheritance and method resolution order
_14.5 Mixin Class
_14.6 Multiple Inheritance in the Real World
_14.7 Inheritance Handling
_14.8 Summary

CHAPTER 15: A Closer Look at Data Type Hints

_15.1 Changes in this chapter
_15.2 Overloaded Signature
_15.3 TypedDict
_15.4 Data type conversion
_15.5 Reading data type hints at runtime
_15.6 Implementing a Generic Class
_15.7 Variability
_15.8 Implementing a Generic Static Protocol
_15.9 Summary

CHAPTER 16 Operator Overloading

_16.1 Changes in this chapter
_16.2 Operator Overloading Basics
_16.3 Unary Operators
_16.4 Overloading the + Operator for Vector Addition
_16.5 Overloading the * Operator for Scalar Multiplication
_16.6 Using @ as an infix operator
_16.7 Summary of Arithmetic Operators
_16.8 Rich comparison operators
_16.9 Compound Assignment Operators
_16.10 Summary

[PART 4 ​​CONTROL FLOW]

CHAPTER 17 Iterators, Generators, and Classic Coroutines

_17.1 Changes in this chapter
_17.2 Sequence of words
_17.3 Why sequences are repeatable: the iter( ) function
_17.4 Iterations and Iterators
_17.5 Sentence class with __iter__( )
_17.6 Leisurely Sentence
_17.7 When is generator expressions appropriate?
_17.8 Arithmetic Sequence Generator
_17.9 Generator functions in the standard library
_17.10 Functions that reduce iterations
_17.11 Subgenerator using yield from
_17.12 Generic iteration
_17.13 Classical Coroutines
_17.14 Summary

CHAPTER 18 with, match, else blocks

_18.1 Changes in this chapter
_18.2 Context Managers and the with Block
_18.3 Case Study: Pattern Matching in lis.py
_18.4 else block after if statement
_18.5 Summary

CHAPTER 19: Python's Concurrency Model

_19.1 Changes in this chapter
_19.2 Overview
_19.3 A brief glossary of terms
_19.4 Hello World Concurrency Version
_19.5 The Real Impact of GIL
_19.6 Custom Process Pool
_19.7 Python in a Multicore World
_19.8 Summary

CHAPTER 20 Concurrent Executors

_20.1 Changes in this chapter
_20.2 Downloading web content simultaneously
_20.3 Running processes with concurrent.futures
_20.4 Executor.map( ) Experiment
_20.5 Downloading while printing progress and handling errors
_20.6 Summary

CHAPTER 21 Asynchronous Programming

_21.1 Changes in this chapter
_21.2 Some definitions
_21.3 asyncio example: domain search
_21.4 New Concept: Waiting
_21.5 Downloading with asyncio and HTTPX
_21.6 Asynchronous Context Manager
_21.7 Improved asyncio download program
_21.8 Delegating a task to an executor
_21.9 Writing an asyncio server
_21.10 Asynchronous Iteration and Asynchronous Iteration Types
_21.11 Asyncio Beyond Asyncio: Curio
_21.12 Specifying data type hints for asynchronous objects
_21.13 Truths and Misconceptions about Asynchronous Methods
_21.14 Summary

[PART 5 Metaprogramming]

CHAPTER 22 Dynamic Attributes and Properties

_22.1 Changes to this chapter
_22.2 Data Wrangling Using Dynamic Properties
_22.3 Calculated Properties
_22.4 Using Properties to Validate Attributes
_22.5 Understanding Properties Properly
_22.6 Implementing a Property Factory
_22.7 Handling attribute removal
_22.8 Key properties and functions for attribute processing
_22.9 Summary

CHAPTER 23 Attribute Descriptors

_23.1 Changes to this chapter
_23.2 Descriptor Example: Attribute Validation
_23.3 Overriding and Non-Overriding Descriptors
_23.4 Method is a descriptor
_23.5 Tips for Using Descriptors
_23.6 Descriptor Docstrings and Deletion Overrides
_23.7 Summary

CHAPTER 24: Class Metaprogramming

_24.1 Changes to this chapter
_24.2 Classes as Objects
_24.3 type: Built-in class factory
_24.4 Class Factory Functions
_24.5 Introducing __init_subclass__( )
_24.6 Improving Classes Using Class Decorators
_24.7 Import Time and Runtime Comparison
_24.8 Metaclass Basics
_24.9 Metaclass Solution for Checked
_24.10 Metaclass Considerations
_24.11 Digging into metaclasses with __prepare__( )
_24.12 Metaclass Key Summary
_24.13 Summary

Detailed image
Detailed Image 1

Publisher's Review
Make Python even greater!
The Ultimate Practical Guide to Mastering Advanced Python Features


Many programmers still try to adapt Python to patterns they've learned from other languages, so they often fail to fully explore Python's unique features and philosophy.
This book presents a more efficient and Python-like coding method to such developers.

We'll introduce Python's unique features, such as tuple unpacking and descriptors, and explore how functions as first-class objects impact design patterns.
It helps you take full advantage of Python's powerful features using only the basic libraries, without relying on external packages.
Based on the environment after Python 3.10, it will be of great help to practical developers in writing efficient code by taking advantage of the added features.

Updated in Edition 2

● Reflects major updates in Python 3
○ Python 3.6+: collections.abc.Collection abstract base class and f-string
○ Python 3.9+: Improved unpacking syntax for dict types, improved mapping merging functionality
○ Python 3.10+: New pattern matching feature, mapping method using match/case

● Overall improvements
○ Update all content to the latest version
○ Added special method content to support asynchronous programming and new features.
○ Add data class builder content
○ Added content for two callables (native coroutines and asynchronous generators)
○ Added data type hints to function signatures
○ Added content on Python's gradual typing system
○ Added content on Python's three improved concurrency methods (threads, processes, and coroutines).
○ Highlighting Python's new metaprogramming features

Target audience

● Python developers who want to become proficient in Python
● Practitioners who want to learn Python's additional features in depth
● Developers who want to learn how to write more efficient and Python-like code

This revised edition is divided into five major parts, each covering a different topic, and is structured as a short book.

● Data structures: sequences, dictionaries, sets, Unicode, data classes
● Functions as objects: first-class functions, related design patterns, type hints in function declarations
● Classes and protocols: composition, inheritance, mixins, interfaces, operator overloading, protocols, static typing
● Control flow: context manager, generator, coroutine, async/await, thread/process pool
● Metaprogramming: New class metaprogramming hooks that replace or simplify properties, property descriptors, class decorators, and metaclasses.
GOODS SPECIFICS
- Date of issue: November 30, 2024
- Page count, weight, size: 1,064 pages | 183*235*60mm
- ISBN13: 9791169211772
- ISBN10: 1169211771

You may also like

카테고리