I have a script which different people may use. I have print statements so people can follow along what the script is doing, and if it breaks where it went wrong, and if a certain step takes a long time which step it was.
Which way for print statements is better in this case and why?
This:
def do_something():
...
print 'doing something'
do_something()
Or this:
def do_something():
print 'doing something'
...
do_something()
I am inclined to think the first is better as it is slightly clearer what is going on when people look at your script; they know there is a print statement before the function is called, and you can add extra detail when sometimes the function name isn't as informative as it could be.
However I see how it could be considered duplication of code. And so the second is better.
But more important than this quite specific question is what general principle would lead you to prefer one over the other?