Press enter or click to view image in full size
Member-only story
If your functions accept five dictionaries, your architecture already has a problem.
Stop Passing Dictionaries Everywhere in Python
Your code works. But it’s slowly turning into an untyped, undocumented mess.
3 min read6 days ago
You’ve seen it. Maybe you’ve written it.
def process_user(data):
name = data["name"]
age = data["age"]
email = data["email"]
is_active = data.get("is_active", False)
...Then somewhere else:
user_data = {
"name": "Aashish",
"age": 27,
"email": "aashish@example.com",
"is_active": True
}
process_user(user_data)Seems harmless.
Until six months later when someone adds "phone_number" in one place but forgets to update three others.
Now your “flexible” dictionary has become a liability.
Let’s talk about why passing dictionaries everywhere is hurting your Python code — and what to do instead.
The Hidden Cost of “Just Use a Dict”
Dictionaries feel convenient because they’re:
- Flexible
- Easy to create