Book Image

Mastering Object-Oriented Python - Second Edition

By : Steven F. Lott
Book Image

Mastering Object-Oriented Python - Second Edition

By: Steven F. Lott

Overview of this book

Object-oriented programming (OOP) is a relatively complex discipline to master, and it can be difficult to see how general principles apply to each language's unique features. With the help of the latest edition of Mastering Objected-Oriented Python, you'll be shown how to effectively implement OOP in Python, and even explore Python 3.x. Complete with practical examples, the book guides you through the advanced concepts of OOP in Python, and demonstrates how you can apply them to solve complex problems in OOP. You will learn how to create high-quality Python programs by exploring design alternatives and determining which design offers the best performance. Next, you'll work through special methods for handling simple object conversions and also learn about hashing and comparison of objects. As you cover later chapters, you'll discover how essential it is to locate the best algorithms and optimal data structures for developing robust solutions to programming problems with minimal computer processing. Finally, the book will assist you in leveraging various Python features by implementing object-oriented designs in your programs. By the end of this book, you will have learned a number of alternate approaches with different attributes to confidently solve programming problems in Python.
Table of Contents (25 chapters)
Free Chapter
1
Section 1: Tighter Integration Via Special Methods
11
Section 2: Object Serialization and Persistence
17
Section 3: Object-Oriented Testing and Debugging

Preface

This book will introduce you to many advanced features of the Python programming language. The focus is on creating the highest quality Python programs possible. This requires exploring design alternatives and determining which design offers the best performance while still being a good fit for the problem that is being solved.

The majority of this book showcases a number of alternatives for a given design. Some will offer better performance, while some will appear simpler or be a better solution to the problem domain. It's essential to locate the best algorithms alongside optimal data structures in order to create the most value with the least computer processing. Time is money, and programs that save time will create more value for their users. Python makes a number of internal features directly available to our application programs. This means that our programs can be very tightly integrated with existing Python features. We can leverage numerous Python features by ensuring that our object-oriented designs (OODs) integrate well.

As we explore different algorithms and data structures, we'll discover different memory and performance alternatives. It's an important OOD skill to be able to work through alternate solutions in order to properly optimize the final application. One of the more important themes of this book is that there's no single best approach to any problem.

As many of the examples as possible have full type hints. A few of the examples rely on packages outside the standard library, where you'll find that type hints are either missing or are incomplete. The examples have to be processed with the mypy tool to confirm the types are used consistently.

As we move toward achieving mastery of object-oriented Python, we'll spend a great deal of time reading Python code from a variety of sources. We'll observe wide variability even within the Python standard library modules. Rather than presenting examples that are all perfectly consistent, we've opted for some inconsistency; the lack of consistency will help to read kinds of code, as seen in various open source projects encountered in the wild.