Dorothea Reher’s Post

A small Python detail that makes function calls safer: * in parameters Sometimes, the most impactful learning moments come from tiny language features. Recently, I revisited the use of * in Python function parameters — and it’s one of those things that quietly improves code clarity and safety. When you place a * in a function signature, it means that all parameters after the * must be passed as keyword arguments. Example: def build(queryset, *, name, url): ... Here’s how it must be called: build(qs, name="test", url="example.com") And here’s what Python prevents you from doing: build(qs, "test", "example.com") # ❌ not allowed Why this matters in real projects: - Makes function calls more readable - Prevents bugs caused by argument order - Protects public APIs from breaking when parameters evolve - Encourages explicit, self-documenting code It’s a small syntax feature, but it communicates intent clearly: these arguments matter and should be named. Another reminder that mastering Python isn’t just about frameworks — it’s about understanding the language itself and using it deliberately.

To view or add a comment, sign in

Explore content categories