Python
Notes on the Python programming language — testing, async, type hints, and practical patterns.
Download and process S3 CSV files in memory using boto3 and tempfile.NamedTemporaryFile without cluttering disk with temporary files.
Use operator.itemgetter for faster sorting and element access with graceful KeyError handling via methodcaller for safer operations.
Fix Django REST Framework to return JSON error responses for 403, 404, 500 errors using middleware instead of default HTML pages.
Learn how Python generators decouple data production from consumption, enabling cleaner code for streaming, polling, and pipeline patterns.
Understand CPython list memory allocation: how lists store pointer references, grow dynamically, and when pre-allocation with [None]*n helps.
Prevent excessive file downloads in Python by streaming with HTTPX and limiting file size with chunk-based validation and memory-safe processing.
Leverage Python's __post_init__ hook to declaratively transform dataclass fields. Automatically serialize data with clean, maintainable code.
Learn efficient patterns for caching database connection objects in Python without import-time side effects or lru_cache complexity.
Fix Python ModuleNotFoundError by using python -m instead of direct script execution to ensure correct sys.path handling for imports.
Mock chained datetime methods in Python tests using unittest.mock to handle immutable datetime objects without external dependencies.
Use Python TypedDict to declaratively define API payload structures. Get type safety for nested dictionaries and improve code maintainability.
Create dynamic pytest fixtures with @pytest.fixture(params) to run tests with multiple configurations and parameter combinations.
Safely modify lists, sets, and dictionaries while iterating using list comprehensions, filters, or copying to avoid skipping elements.
Production-ready GitHub Actions workflow for Python with multi-OS testing, dependency caching, automated updates, and daily scheduled runs.
Use Python's Self type from PEP 673 to annotate methods returning class instances, eliminating complex forward references and TypeVars.