AI Features
Log In
0% completed
All Lessons
Free Lessons (3)
Object-Oriented Design
Getting Started
Introducing Object-Oriented Paradigm
Objects and Classes
Attributes and Behaviors
Hiding Details and Creating the Public Interface
Composition and Aggregation
Inheritance
Case Study
Context View
Logical View
Process View
Development View
Physical View
Challenge: Design an Order Processing System
Solution: Design an Order Processing System
Quiz: Object-Oriented Design
Summary
Objects in Python
Type Hints
Type Checking
Creating Python Classes
Initializing the Object
Type Hints and Defaults
Modules and Packages
Organizing Modules
Organizing Code in Modules
Who Can Access My Data?
Case Study
Samples and Their States
Sample State Transitions
Class Responsibilities
The TrainingData Class
Challenge: Build a To-Do Application
Solution: Build a To-Do Application
Quiz: Objects in Python
Summary
When Objects Are Alike
Basics of Inheritance
Extending Built-in Functions
Overriding and Super Functions
Multiple Inheritance
The Diamond Problem
Different Sets of Arguments
Polymorphism
Case Study
Logical View
Challenge: Build a Testing System
Solution: Build a Testing System
Quiz: When Objects Are Alike
Summary
Expecting the Unexpected
Exceptions
Raising an Exception
The Effects of an Exception
Handling Exceptions
The Exception Hierarchy
Defining Our Own Exceptions
Exceptions Aren’t Exceptional
Case Study
Context and Processing View
Bad Data and Bad Behavior
Creating Samples From CSV Files
Validating Enumerated Values
Reading CSV Files
Quiz: Expecting the Unexpected
Summary
When to Use Object-Oriented Programming
Treat Objects as Objects
Adding Behaviors to Class Data With Properties
Properties in Detail
Decorators—Another Way to Create Properties
Deciding When to Use Properties
Manager Objects
Removing Duplicate Code
Case Study
The Sample Class Hierarchy
The Purpose Enumeration
Challenge: Build a Banking System
Solution: Build a Banking System
Quiz: When to Use Object-Oriented Programming
Summary
Abstract Base Classes and Operator Overloading
Introduction
Abstract Base Class and Concrete Class
The ABCs of Collections
Abstract Base Classes and Type Hints
The collections.abc Module
Creating Our Own Abstract Base Class
Demystifying the Magic
Operator Overloading
Extending Built-ins
Metaclasses
Case Study
A Shuffling Strategy for Partitioning
An Incremental Strategy for Partitioning
Challenge: Construct a Library Management System
Solution: Construct a Library Management System
Quiz: Abstract Base Classes and Operator Overloading
Summary
Python Data Structures
Empty Objects
Tuples and Named Tuples
Named Tuples via typing.NamedTuple
Dataclasses
Dictionaries
Dictionary: Use Cases
Using defaultdict
Counter
Lists
Sorting Lists
Sets
Types of Queues
Case Study
Frozen Dataclasses
NamedTuple Classes
Challenge: Create a Customer Relationship Management System
Solution: Create a Customer Relationship Management System
Quiz: Python Data Structures
Summary
Object-Oriented and Functional Programming Intersection
Introduction
Python Built-in Functions
An Alternative to Method Overloading
Default Values for Parameters
Variable Argument Lists
Unpacking Arguments
Functions Are Objects, Too
Function Objects and Callbacks
Using Functions to Patch a Class
Callable Objects
File I/O
Context Management
Case Study
Data Classification
Partition Function
Challenge: Build a Sales Report Generator
Solution: Build a Sales Report Generator
Quiz: Object-Oriented and Functional Programming Intersection
Summary
Strings, Serialization, and File Paths
Introduction to Strings
String Manipulation
String Formatting
f-strings Containing Python Code
Custom Formatters
Strings Are Unicode
Regular Expressions
Matching a Selection of Characters
Repeating and Grouping Characters Patterns
Parsing Information With Regular Expressions
Filesystem Paths
Serializing Objects
Customizing Pickles
Serializing Objects Using JSON
Case Study
CSV Dictionary Reader
CSV List Reader
JSON Serialization
JSON Validation
Challenge: Create a Data Management System
Solution: Create a Data Management System
Quiz: Strings, Serialization, and File Paths
Summary
The Iterator Pattern
Introduction
Iterators
Comprehensions
Set and Dictionary Comprehensions
Generator Expressions
Generator Functions
Yield Items From Another Iterable
Generator Stacks
Case Study
Multiple Partitions
Testing
The Essential k-NN Algorithm
Challenge: Students Performance Tracking System
Solution: Students Performance Tracking System
Quiz: The Iterator Pattern
Summary
Common Design Patterns
Introduction
The Decorator Pattern
Decorators in Python
The Observer Pattern
The Strategy Pattern
The Command Pattern
The State Pattern
The Singleton Pattern
Case Study
Challenge: Create a Company's Logging System
Solution: Create a Company's Logging System
Quiz: Common Design Patterns
Summary
Advanced Design Patterns
Introduction
The Adapter Pattern
The Facade Pattern
The Flyweight Pattern
A Flyweight Example In Python
The Abstract Factory Pattern
Abstract Factories In Python
The Composite Pattern
The Template Pattern
Case Study
Challenge: Develop a Data Aggregation System
Solution: Develop a Data Aggregation System
Quiz: Advanced Design Patterns
Summary
Testing Object-Oriented Programs
Introduction
Coding With Tests
Unit Testing With unittest
Unit Testing With pytest
Skipping Tests With pytest
Imitating Objects Using Mocks
Test-Driven Development Insights
Case Study
Unit Testing the Hyperparameter Class
Quiz: Testing Object-Oriented Programs
Summary
Concurrency
Introduction
Threads
Problems with threads
Multiprocessing
Multiprocessing Pools
Queues
Problems with Multiprocessing
Futures
AsyncIO
AsyncIO for Networking
A Log Writing Demonstration
AsyncIO Clients
The Dining Philosophers Benchmark
Case Study
Challenge: Build a Sensor Monitoring System
Solution: Build a Sensor Monitoring System
Quiz: Concurrency
Summary
Conclusion
Wrap Up
Project
Build a Python Airline Reservation System
Home
Courses
Building Robust Object-Oriented Python Applications and Libraries
Introduction
Learn about the common design patterns in Python.
We'll cover the following...
Overview
Overview
In the previous chapter, we
...
Ask