Chapter 1, Current Status of Python, showcases the current state of the Python
language and its community. We will see how Python is constantly changing and
why it is changing. We will learn what to do with old Python 2 code and how to be
constantly up to date with what is currently happening in the Python community.
Chapter 2, Modern Python Development Environments, describes modern ways
of setting up repeatable and consistent development environments for Python
programmers. We will learn differences between application-level and system-
level isolation. We will concentrate on two popular tools for environment isolation,
virtualenv-type environments and Docker containers, but will also review other
alternatives. At the end of the chapter, we will discuss common productivity tools
that are extremely useful during development.
Chapter 3, New Things in Python, showcases recent Python language additions. We
will review the most important Python syntax changes that happened in the last four
releases of Python. We will also take a look at exciting changes that are scheduled
for the next major Python release—Python 3.10.
Chapter 4, Python in Comparison with Other Languages, shows how Python compares
to other languages. We will learn what programming idioms are and how to
recognize them in code. We will take a deeper look into key elements of Python's
object-oriented programming model and how it is different from other object-
oriented programming languages but will also discuss other popular programming
language features like descriptors, decorators, and dataclasses. This chapter should
allow programmers with experience in other languages to safely land in the Python
ecosystem.
Chapter 5, Interfaces, Patterns, and Modularity, discusses elements of Python that allow
for implementing various reusable design patterns. If focuses on the concept of class
interfaces and how they can be implemented in Python. It also discusses inversion of
control and dependency injection—two extremely useful but not necessarily popular
programming techniques.
Chapter 6, Concurrency, explains how to implement concurrency in Python using
different approaches and libraries. It features three major concurrency models:
multithreading, multiprocessing and asynchronous programming. In this chapter we
will learn key differences between those models and how to use them effectively.
Chapter 7, Event-Driven Programming, describes what event-driven programming is
and how it relates to asynchronous programming and different concurrency models.
We will present various approaches to event-driven programming along with useful
libraries.
Chapter 8, Elements of Metaprogramming, presents an overview of common approaches
to metaprogramming available to Python programmers. We will learn about
common metaprogramming techniques like decorators, as well as metaclasses and
code generation patterns.
Chapter 9, Bridging Python with C and C++, explains how to integrate code written in
different languages in your Python application. We will learn when extensions in C
can be useful and how to create them.
Chapter 10, Testing and Quality Automation, is about providing automated testing and
quality processes. We will learn about a popular testing framework—Pytest—and
many useful testing techniques. We will also cover tools that can be used to assess
code quality metrics and improve code style in fully automated way.
Chapter 11, Packaging and Distributing Python Code, describes the current state of
Python packaging and best practices for creating packages that are to be distributed
as open source code in the Python Package Index (PyPI). We will also cover the
topics of packaging applications for web development and creating standalone
Python executables for desktop applications.
Chapter 12, Observing Application Behavior and Performance, discusses the topic of
application observability. We will learn about Python logging systems, how to
monitor application metrics and perform distributed transaction tracing. We will
also learn how to scale simple observability practices to large-scale distributed
systems.
Chapter 13, Code Optimization, discusses the basic rules of optimization that
every developer should be aware of. We will learn how to identify application
performance bottlenecks and how to use common profiling tools. We will also learn
common optimization techniques and strategies that can be easily applied in many
situations once you know where the bottleneck is.
Python is used in a wide range of domains owing to its simple yet powerful nature. Although writing Python code is easy, making it readable, reusable, and easy to maintain can be challenging. Complete with best practices, useful tools, and standards implemented by professional Python developers, this fourth edition will help you in not only overcoming such challenges but also learning Python's latest features and advanced concepts.
The book begins with a warm-up, where you will catch-up with the latest Python improvements, syntax elements, and interesting tools to boost your development efficiency. Further, the initial few chapters should allow experienced programmers coming from different languages to safely land in the Python ecosystem.
As you progress, you will explore common software design patterns and various programming methodologies, such as event-driven programming, concurrency, and metaprogramming. You will also go through complex code examples and try to solve meaningful problems by bridging Python with C and C++, writing extensions that benefit from the strengths of multiple languages. Finally, you will understand the complete lifetime of any application after it goes live.
By the end of the book, you should be proficient in writing efficient and maintainable Python code.
Explore modern ways of setting up repeatable and consistent Python development environments
Effectively package Python code for community and production use
Learn modern syntax elements of Python programming, such as f-strings, enums, and lambda functions
Demystify metaprogramming in Python with metaclasses
Write concurrent code in Python
Extend and integrate Python with code written in different languages
The Python programming book is intended for expert programmers who want to learn Python's advanced-level concepts and latest features.
Anyone who has basic Python skills should be able to follow the content of the book, although it might require some additional effort from less experienced programmers. It should also be a good introduction to Python 3.9 for those who are still a bit behind and continue to use other older versions.