E-Book, Englisch, 542 Seiten
Lott / Phillips Python Object-Oriented Programming
5. Auflage 2025
ISBN: 978-1-83664-258-9
Verlag: De Gruyter
Format: EPUB
Kopierschutz: 0 - No protection
Learn how and when to apply OOP principles to build scalable and maintainable Python applications
E-Book, Englisch, 542 Seiten
ISBN: 978-1-83664-258-9
Verlag: De Gruyter
Format: EPUB
Kopierschutz: 0 - No protection
Learn to write effective, maintainable, and scalable Python applications by mastering object-oriented programming with this updated fifth edition. Whether you're transitioning from scripting to structured development or refining your OOP skills, this book offers a clear, practical path forward.
You'll explore Python's approach to OOP, from class creation and inheritance to polymorphism and abstraction, while discovering how to make smarter decisions about when and how to use these tools. You'll apply what you learn through hands-on examples and exercises.
Updated for Python 3.13, this edition simplifies complex topics such as abstract base classes, testing with unittest and pytest, and async programming with asyncio. It introduces a new chapter on Python's type hinting ecosystem-crucial for modern Python development.
Written by long-time Python experts Steven Lott and Dusty Phillips, this edition emphasizes clarity, testability, and professional software engineering practices. It helps you move beyond scripting to building well-structured, production-ready Python systems.
By the end of this book, you'll be confident in applying OOP principles, design patterns, type hints, and concurrency tools to create robust and maintainable Python applications.
Autoren/Hrsg.
Fachgebiete
Weitere Infos & Material
Preface
The Python programming language is extremely popular and used for a variety of applications. The Python language is designed to make it relatively easy to create small programs. To create more sophisticated software, we need to acquire a number of important programming and software design skills.
This book describes the object-oriented approach to creating programs in Python. It introduces the terminology of object-oriented programming, demonstrating software design and Python programming through step-by-step examples. It describes how to make use of inheritance and composition to build software from individual elements. It shows how to use Python’s built-in exceptions and data structures, as well as elements of the Python standard library. A number of common design patterns are described with detailed examples.
This book covers how to write automated tests to confirm that our software works. It also shows how to use the various concurrency libraries available as part of Python, making effective use of multiple cores and multiple processors in a modern computer.
Who this book is for
This book targets people who are new to object-oriented programming in Python. It assumes basic Python skills and familiarity with Python’s tools, including PIP for installing packages. Starting with the fifth edition, we’re assuming the reader has been through the first 8 sections of https://docs.python.org/3/tutorial/. For readers with a background in another object-oriented programming language, this book will expose many distinctive features of Python’s approach.
Because of Python’s use for data science and data analytics, this book touches on a few math and statistics concepts. Some knowledge in these areas can help to make the applications of the concepts more concrete.
What this book covers
This book is divided into four overall sections. The first six chapters provide the core principles and concepts of object-oriented programming and how these are implemented in Python. The next three chapters take a close look at Python built-in features through the lens of object-oriented programming. This is followed by three chapters focused on common design patterns and how these can be handled in Python. The final section covers two additional topics: testing and concurrency.
Chapter 1, introduces the core concepts underlying object-oriented design. This provides a road map through the ideas of state and behavior, attributes and methods, and how objects are grouped into classes. This chapter looks at the basic principles of object-oriented design.
Chapter 2, shows how class definitions work in Python. This will include the type annotations, called type hints, class definitions, modules, and packages. We’ll talk about practical considerations for class definition and encapsulation. We’ll touch on how to extend Python with additional libraries and how to manage virtual environments.
Chapter 3, addresses how classes are related to each other. This will include how to make use of inheritance and multiple inheritance. We’ll look at the concept of polymorphism among the classes in a class hierarchy. We’ll look closely at how Python’s approach of ”duck typing” works.
Chapter 4, looks closely at Python’s exceptions and exception handling. We’ll look at the built-in exception hierarchy. We’ll also look at how unique exceptions can be defined to reflect a unique problem domain or application.
Chapter 5, dives more deeply into design techniques. It looks closely at data and behavior and how these are reflected in class design. This chapter will look at how attributes can be implemented via Python’s properties.
Chapter 6, is a deep dive into the idea of abstraction, and how Python supports abstract base classes. This will involve comparing duck typing with more formal methods of Protocol definition. It will include techniques for overloading Python’s built-in operators. We will also look at metaclasses and how these can be used to modify class construction.
Chapter 7 examines type hints and how they’re used in object-oriented programming. We’ll look at tools for validating the type annotations. We’ll look at packages to help with run-time type checking, also.
Chapter 8, examines a number of Python’s built-in collections. This chapter examines tuples, dictionaries, lists, and sets. It also looks at how dataclasses and named tuples can simplify a design by providing a number of common features of a class.
Chapter 9, looks at Python constructs that aren’t simply class definitions. While all of Python is object-oriented, function definitions allow us to create callable objects without the clutter of a class definition. We’ll also look at Python’s context manager construct and the with statement.
Chapter 10, describes the ubiquitous concept of iteration in Python. All the built-in collections are iterable, and this design pattern is central to a great deal of how Python works. We’ll look at Python comprehensions and generator functions, also.
Chapter 11, looks at some common object-oriented design patterns. This will include the Decorator, Observer, Strategy, Command, State, and Singleton patterns.
Chapter 12, looks at some more advanced object-oriented techniques. This will include the Adapter, Façade, Flyweight, Abstract Factory, Composite, and Template design patterns.
Chapter 13, shows how to use tools like unittest and pytest to provide an automated unit test suite for a Python application. This will look at some more advanced testing techniques, including the use of mock objects to isolate the unit under test.
Chapter 14, looks at how we can make effective use of multi-core and multi-processor computer systems to do computations rapidly. These techniques can help create software that is responsive to external events. We’ll look at threads and multiprocessing, as well as Python’s asyncio module.
To get the most out of this book
All the examples were tested with Python 3.12.5. The pyright tool, version 1.1, was used to confirm that the type hints were consistent.
Some of the examples depend on an internet connection to gather data. These interactions with websites generally involve small downloads.
Some of the examples involve packages that are not part of Python’s built-in standard library. In the relevant chapters, we note the packages and provide the install instructions. All of these extra packages are in the Python Package Index, at https://pypi.org.
Download the example code files
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Python-Object-Oriented-Programming-5E.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/ Check them out!
Download the color images
We also provide a PDF file that has color...




