Python tutorials
87 articles · page 3 of 5Hand-written tutorials, ordered as a recommended learning path.
- 41 Mocking Guide Master Python's unittest.mock library for testing. Learn Mock, MagicMock, patch, side_effect, and spec with real-world examples for unit testing.
- 42 Profiling & Performance Learn how to profile Python code with cProfile, line_profiler, memory_profiler, and timeit to identify slow functions, memory leaks, and optimize runtime performance.
- 43 Protocol Classes Learn how to use Python Protocol classes for structural subtyping, duck typing with static checks, and writing flexible interfaces without inheritance.
- 44 Socket Programming Learn Python socket programming from scratch. Build TCP and UDP servers and clients, handle multiple connections, and implement a simple chat application.
- 45 subprocess Guide Learn how to run shell commands from Python using the subprocess module with subprocess.run, Popen, pipes, error handling, and security best practices.
- 46 Weak References & GC Understand Python's garbage collection, reference counting, and how weak references prevent memory leaks in caches, observers, and circular structures.
- 47 ABCs vs Protocols Understand the difference between Abstract Base Classes and Protocols in Python. Learn when nominal typing beats structural typing and vice versa.
- 48 asyncio Advanced Go beyond basic async/await with structured concurrency, task groups, semaphores, cancellation, and error handling patterns in Python asyncio.
- 49 Closures & Scoping Understand how Python closures capture variables, the LEGB scope resolution rule, and common pitfalls like late binding in loops.
- 50 collections Module Master Python's collections module with defaultdict, Counter, deque, namedtuple, and OrderedDict through practical, real-world examples.
- 51 Dataclasses vs Pydantic Compare Python dataclasses and Pydantic models side by side. Learn their strengths, performance traits, and how to pick the right tool for your project.
- 52 Dependency Injection Learn how to apply dependency injection in Python using constructor injection, factory functions, and simple containers -- no framework required.
- 53 Design Patterns Learn how to implement the Strategy, Factory, and Observer design patterns in Python using idiomatic constructs like first-class functions and protocols.
- 54 functools Deep Dive Explore the functools module beyond caching. Learn partial, reduce, singledispatch, cached_property, and total_ordering with practical examples.
- 55 GIL Explained Understand the Global Interpreter Lock in CPython, why it exists, how it affects concurrency, and strategies to work around it.
- 56 Packaging A complete guide to modern Python packaging using pyproject.toml, build backends, and best practices for distributing your library.
- 57 pytest Advanced Master pytest fixtures, parametrize, monkeypatch, and custom markers to write maintainable, expressive tests for production Python code.
- 58 Structured Logging Move beyond print-style logging. Learn structured logging with structlog, correlation IDs, context binding, and integrating with observability tools.
- 59 Concurrency Compare Python's concurrency models -- threading, multiprocessing, and asyncio -- with practical examples and performance guidance.
- 60 Context Managers Learn how Python context managers work under the hood, build custom ones with classes and contextlib, and explore advanced patterns.