I would have the opinion and good practices in script programming about using print statements to materialize the control flow (I usually use an anchor mark, then the name of the function just entered, and eventually the step number in the control flow). I usually then print crucial variable to check if all is going well, and I am pretty explanatory there too, naming each variable before printing its value.

Is it ok to do this way (at least in scripts that are not made for production)? I must say that I use this even more than comments (I usually only use comments to explain what is a variable, why it should be that type or use a method instead of another, or to unravel things that could not be so obvious after three months far from the code).

Is it ok, or should I be less verbose, and more rely on comments. It's an habit I had since I have been coding using OOP, in order to clarify the flow and help me debug, but actually that might be a bad personal preference.

(I don't think this question duplicates this one: Should code comments explain the control flow?)

1 Answer 1


This isn't really a "should" question. Does it work for you? Ok then do it. Scripts often have minimal debugging facilities so the old "printf" is jolly useful. Consider having a "verbose" mode and a "quiet" mode.

If your programs get really complicated you're probably better off with a debugger (or perhaps just fix your unit tests...)

  • In fact if your "script" uses OOP I'd submit it's pretty much a program and perhaps more sophisticated debugging/validation might be worth while, Aug 10, 2017 at 13:00
  • Thanks. I ask because I code for myself, nearly nobody who can read code and program use it. I wrote "script" in the sense of these not being programs that reach someone else, they are only executed in IDE (spyder actually, I use python, so another reason using the word script). As for unit testing, it is not always possible to do without the whole program flow I usually reprocess large data tables and I am not always able to foresee every case which could fail a function. So I usually test my functions parts or subparts in console with expected types, but then test code on the whole.
    – Ando Jurai
    Aug 10, 2017 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.