About 149 results
https://rednafi.com/python/uniform-error-response-in-drf/ · 20 Jan 2022
Standardize Django REST Framework error responses using custom exception handlers to match Microsoft's REST API guidelines format.
https://rednafi.com/python/difference-between-typevar-and-union/ · 19 Jan 2022
Understand when to use constrained TypeVar vs Union in Python type hints for consistent types across function parameters and return values.
https://rednafi.com/python/lru-cache-on-methods/ · 15 Jan 2022
Avoid memory leaks when caching instance methods with lru_cache by making cache containers local to instances instead of global.
https://rednafi.com/python/text-cropping-with-textwrap-shorten/ · 6 Jan 2022
Crop text to character limits without breaking words using Python's textwrap.shorten for clean truncation with customizable placeholders.
https://rednafi.com/python/string-interning/ · 5 Jan 2022
Learn how Python's string interning optimizes memory by caching strings and using sys.intern() for custom string caching to improve performance.
https://rednafi.com/python/structural-subtyping/ · 4 Dec 2021
Implement Go-style structural subtyping in Python with Protocol for duck typing and interface-based APIs without inheritance dependencies.
https://rednafi.com/python/attribute-delegation-in-composition/ · 28 Nov 2021
Implement automatic attribute delegation in Python composition using __getattr__ magic method for inheritance-like attribute access patterns.
https://rednafi.com/python/access-classmethod-like-property/ · 26 Nov 2021
Learn how to access Python classmethods like property methods using metaclasses or Python 3.9+ decorator stacking for Enum classes.
https://cuducos.me/como-organizar-um-projeto-em-django.html · 24 Nov 2021
Em 2016 começamos a Operação Serenata de Amor e uma das necessidades da nossa equipe de cientistas de dados era ter uma ferramenta fácil para ver os detalhes de qualquer reembolso específico feito pela Câmara dos Deputados a parlamentares. Assim nasc...
https://rednafi.com/python/use-init-subclass-hook-to-validate-subclasses/ · 20 Nov 2021
Validate subclass schemas at definition time with Python's __init_subclass__ hook, a cleaner alternative to metaclasses for enforcing structure.