About 149 results
https://rednafi.com/python/annotate-args-and-kwargs/ · 8 Jan 2024
Properly annotate Python *args and **kwargs with heterogeneous types using Unpack, TypedDict, and modern type hints from PEP-692.
https://rednafi.com/python/statically-enforcing-frozen-dataclasses/ · 4 Jan 2024
Enforce immutable dataclasses at type-check time with @final decorator to catch mutations before runtime without frozen=True performance cost.
https://rednafi.com/python/debug-dockerized-apps-in-vscode/ · 22 Dec 2023
Set up VSCode debugger for containerized Python applications using debugpy. Step-by-step guide with Docker Compose and launch configurations.
https://rednafi.com/python/dataclasses-and-methods/ · 16 Dec 2023
Why you shouldn't add state-mutating methods to Python dataclasses. Maintain semantic clarity and use dataclasses as pure data containers.
https://marko.tech/journal/the-joy-of-virtual-environments-in-python · 25 Sep 2023
A simple guide on how to determine disk space usage on a Linux/Unix system.
https://rednafi.com/python/tame-conditionals-with-bitmasks/ · 29 Jul 2023
Replace complex nested conditionals with Python's enum.Flag and bitmasks for cleaner, more maintainable logic using bitwise operations.
https://rednafi.com/python/memory-leakage-in-descriptors/ · 16 Jul 2023
Prevent memory leaks in Python descriptors by using weakref to avoid hard references that prevent garbage collection of validated objects.
https://rednafi.com/python/unix-style-pipeline-with-subprocess/ · 14 Jul 2023
Build Unix-style command pipelines in Python using subprocess.run with stdout piping for efficient process chaining and output capture.
https://rednafi.com/python/enable-repeatable-lazy-iterations/ · 13 Jul 2023
Create reusable generators by implementing __iter__ in a class, allowing multiple lazy iterations without memory overhead or repeated function calls.
https://rednafi.com/python/escape-template-pattern/ · 1 Jul 2023
Replace inheritance-based template pattern with composition and Protocol types to create cleaner, testable Python code without namespace pollution.