r/Python • u/Pharaoh_Bellhop8 • 1h ago
Discussion I've started treating the output of my little Python scripts as a user interface
I inherited a bunch of internal Python scripts at work last year. Most of them were perfectly readable, did their job and had been running for years without any major issues.
The annoying part was figuring out what they'd actually done.
One would print "Done" whether it processed 400 files or found nothing to process. Another would silently skip invalid records. To understand the result of a successful run I sometimes had to read the source code.
I've since developed a habit of ending even fairly trivial scripts with a small summary of what was found, what changed, what was skipped and why.
It's probably the smallest change I've made to my coding habits with the biggest practical payoff. Especially when revisiting something I wrote six months ago.
I think we spend a disproportionate amount of time making Python code pleasant for other developers to read compared to making Python programs pleasant for other people to actually run.