Hey Pythonista,
I recently shared a Python tip that blew up online.
It was about overriding the `__or__` method to mimic Unix-style piping, chaining functions like this:
pipeline = double | square print(pipeline(3)) # 36
It’s clean, composable, and readable…
But not everyone agreed. 🤔
💚 Pros:
Elegant functional composition
Familiar to devs coming from shell or Elixir
Inspired frameworks like LangChain
😬 Cons:
Overloading operators can hurt readability
Breaks expectations of what `|` usually means
Could be hard to maintain long-term
---
And that’s what made it fun: a lively debate from dozens of developers with strong opinions, use cases, and alternatives.
It also shows how the Zen of Python’s “There should be one – and preferably only one – obvious way to do it” isn’t always so clear-cut. Sometimes, the best path is ambiguous and that’s where the learning happens.
We explore exactly these kinds of topics in our 1:1 coaching: real-world Python patterns, practical design decisions, and how to think through code like a professional.
Join our PDM coaching program and start building like a real developer. Work 1:1 with us and we'll guide you through real projects, real patterns, and real growth.
Always keep learning + improving!
- Bob Co-founder, Pybites
|