dimanche 19 juillet 2020

Conditional print in python, without writing an IF for each one of them

I write many print(...) lines in the code to verify the middle results.

These are handy when you need them, but when everything works well, I need to commit/delete each one of them. Sometimes I found that I may need them again... then I have to go though each print(...) line again.

So is there a switch, that could activate & deactivate those tmp-print lines? While not influencing other print lines that I always want to activate.

Ps: No one wants to do it with if in each line:

if I_want_tmp_print:

   print("one of my 100 tmp print lines")

Aucun commentaire:

Enregistrer un commentaire