Python Programming II
Advanced Python: object-oriented design, Pythonic patterns, performance, packaging, and capstone projects.
31 lessons
Estimated lesson study time: 489 minutes
Lesson estimates are a guide, not a deadline. Allow extra time for practice, projects, and review.
Learn AI & Technology Access gives you full access to all 19 tracks and 552 lessons after sign-up and onboarding. No time limit, paid subscription, or payment card required.
Start Learn AI & Technology AccessIncludes three AI Tutor answers across these courses. AI-generated content remains subject to Learn’s monthly allowance.
Track overview
Extend your Python skills with object-oriented design, Pythonic patterns, data classes, typing, performance, packaging, and quality. Capstone and advanced work connect design choices with maintainable projects and repeatable tests.
Who this track is for
Python learners ready to move beyond introductory scripts.
Before you begin
Be comfortable with Python variables, control flow, functions, modules, and basic data structures. Python Programming is the natural starting point if those are unfamiliar.
What you will work toward
Practice structuring and packaging Python projects, improving performance, and using fixtures, mocks, parametrization, and coverage to guide testing.
Complete lesson outline
1. Object-Oriented Python
4 lessons
1.1 Classes and Instances
14 minutes- Define classes with attributes and methods
- Initialize instance state with __init__
- Distinguish class attributes from instance attributes
1.2 Inheritance and super()
15 minutes- Create subclasses that extend a base class
- Reuse parent behavior with super()
- Override methods to specialize behavior
1.3 Dunder Methods
15 minutes- Customize object representation with __repr__ and __str__
- Implement comparison and arithmetic dunder methods
- Explain how dunder methods integrate with Python syntax
1.4 Composition over Inheritance
15 minutes- Model has-a relationships with composition
- Delegate behavior to collaborating objects
- Explain when composition beats deep inheritance
2. Pythonic Patterns
4 lessons
2.1 Decorators
16 minutes- Wrap functions with decorators to add behavior
- Preserve metadata using functools.wraps
- Build decorators that accept arguments
2.2 Generators and Iterators
15 minutes- Produce values lazily with generator functions
- Implement the iterator protocol with __iter__ and __next__
- Explain how generators save memory on large sequences
2.3 Context Managers
15 minutes- Manage resources with the with statement
- Build context managers using __enter__ and __exit__
- Simplify context managers with contextlib
2.4 Functional Tools
15 minutes- Transform data with map, filter, and reduce
- Compose small functions for clarity
- Use functools.partial to preset arguments
3. Data Classes and Typing
4 lessons
3.1 Data Classes
14 minutes- Declare structured records with the dataclass decorator
- Set defaults and use field() for mutable defaults
- Create frozen, immutable data classes
3.2 Protocols and Structural Typing
16 minutes- Define interfaces with typing.Protocol
- Enable duck typing with structural subtyping
- Explain how protocols differ from abstract base classes
3.3 Generics and Type Variables
16 minutes- Parameterize functions and classes with type variables
- Write reusable generic containers
- Use bounded type variables to constrain types
3.4 Validation with Pydantic
16 minutes- Model and validate data with Pydantic models
- Coerce and constrain fields with validators
- Parse untrusted input into typed objects
4. Performance
4 lessons
4.1 Profiling Python Code
15 minutes- Measure execution time with timeit
- Find hot spots using cProfile
- Interpret profiling output to guide optimization
4.2 Algorithmic Complexity
16 minutes- Reason about time and space complexity with Big-O
- Choose data structures for efficient operations
- Replace quadratic patterns with linear alternatives
4.3 Caching and Memoization
15 minutes- Cache expensive results with functools.lru_cache
- Choose cache keys and size limits wisely
- Explain when caching helps versus harms
4.4 Multiprocessing vs Threading
17 minutes- Distinguish CPU-bound from I/O-bound workloads
- Parallelize CPU work with multiprocessing
- Explain the impact of the global interpreter lock
5. Packaging and Quality
4 lessons
5.1 Project Layout
14 minutes- Structure a project with a src layout
- Separate package code from tests and scripts
- Explain why a clear layout aids maintainability
5.2 Packaging and Publishing
16 minutes- Configure metadata and dependencies in pyproject.toml
- Build a wheel and source distribution
- Publish a package to an index with twine
5.3 Linting and Formatting
14 minutes- Enforce style automatically with a formatter
- Catch bugs and smells with a linter
- Configure rules in pyproject.toml
5.4 Continuous Integration Basics
15 minutes- Automate tests and checks on every push
- Define a CI workflow with jobs and steps
- Explain how CI catches regressions early
6. Capstone Projects
6 lessons
6.1 Capstone: Web Scraper
18 minutes- Fetch and parse web pages responsibly
- Extract structured data with a parser
- Respect rate limits and robots rules
6.2 Capstone: Data Pipeline
18 minutes- Design an extract, transform, load pipeline
- Chain stages that stream records efficiently
- Handle failures and log progress along the way
6.3 Capstone: CLI Suite with Tests
18 minutes- Build a multi-command CLI application
- Cover the commands with automated tests
- Package the CLI as an installable entry point
6.4 Capstone: Publishing a Package
18 minutes- Prepare a project for public release
- Version, tag, and build distributable artifacts
- Publish and verify installation from an index
6.5 Capstone: REST API Service
18 minutes- Design REST endpoints with clear request and response models
- Validate input and return meaningful error responses
- Cover the API with automated integration tests
6.6 Capstone: Async Task Runner
18 minutes- Run many I/O-bound tasks concurrently with asyncio
- Bound concurrency with a semaphore to avoid overload
- Aggregate results and handle partial failures
7. Advanced Python
5 lessons
7.1 Threads, Processes, and the GIL
15 minutes- Contrast threads and processes for CPU-bound versus IO-bound work
- Explain how the Global Interpreter Lock affects threaded code
- Choose the right concurrency model for a workload
7.2 Typing Deep Dive: Generics and Protocols
16 minutes- Write generic functions and classes with type parameters
- Define structural interfaces using Protocol
- Explain how a type checker catches errors before runtime
7.3 Profiling and Performance Tuning
15 minutes- Measure hot paths with cProfile and timeit
- Interpret profiler output to find bottlenecks
- Apply targeted optimizations backed by measurement
7.4 Packaging for Distribution
15 minutes- Configure a project with pyproject.toml and metadata
- Build a wheel and source distribution
- Explain how entry points expose command-line tools
7.5 Testing Strategies and Fixtures
16 minutes- Organize tests with fixtures and parametrization
- Isolate code under test using mocks and fakes
- Explain how coverage guides where to add tests