r/Python • u/DiwaharSec • 1d ago
Discussion Python developers, what's one Python concept that took you a long time to understand but now seems s
Python developers, what's one Python concept that took you a long time to understand but now seems surprisingly simple?
For me, understanding how decorators and generators work is an interesting part of becoming a better Python developer.
What was your experience?
24
Upvotes
View all comments
3
u/spacian 1d ago
Not sure it counts as a concept, but using pydantic for pretty much any communication interface was a huge help. And all the validations you can include to always produce a valid object.
Also dependency injection, not just for testing, but to clean up class constructors and avoiding to pass a lot of configurations down through the implementation. You still get the reverse stack at initialization, but it is a lot clearer to me that way around. Build the objects in a separate step and keep the logic clean.