Posts by Flavio Curella

Flavio Curella

Dataclasses and attrs: when and why

Python 3.7 introduced dataclasses, which design is based on the "attrs" library. This article will show the way I use dataclasses and attrs, why I think you should use both, and why I think attrs is still very relevant.

Flavio Curella

Pro-Tip - Slugs as primary keys

A very common pattern in a Django Project is to have some kind of 'model-type' relationship, where you have some kind of object that can only belong to one of the types defined in the database.

Flavio Curella

Pro-Tip - Sentinel values in Python

It is often necessary to differentiate between an argument that has not been provided, and an argument provided with the value `None`. For that purpose, we create what's called a 'sentinel value'.

Flavio Curella

Today I Learned - Caching uuid's for the win!

More and more often, we see schema designs that use UUIDs as primary keys. That's a valid choice if you're concerned about sharding and partitioning your database, but it has its own drawbacks, sometimes in unexpected places.

Flavio Curella

Check This Out - Using Private Packages in Python

With companies moving to microservices, it's becoming common to have a system scattered across multiple repositories. It's frequent to abstract common patterns and code into private repositories that are then included in each service. But using packages from private repos with Python can be tricky. This guide will guide you through the necessary steps.

Flavio Curella

Pro-Tip - reverse()'s soulmate resolve()

Have a URL but can't figure out what view it is supposed to use? Use resolve() to easily and quickly determine it just as Django does.