(Dec-11-2017, 07:03 AM)buran Wrote: I do, for small scripts. For a bigger projects I prefer proper logging, with different levels, e.g. DEBUG, INFO, ERROR, CRITICAL, etc. and different logging streams/handlers - stdout, mail, file, etc.
so what if, at some point in the code, around where some incorrect value is calculated, you wonder what some intermediate value is. what kind of "proper logging" gives you that? does it keep a record of every statement executed, every variable assignment value, and the values of every conditional, that you can just lookup that will lead you to an "ah ha! moment"?
(Dec-11-2017, 01:51 PM)mpd Wrote: Combination of the logging module and IDE (PyCharm) debugger. I never EVER use unconditional print statements; people forget to delete them and they show up exactly when you don't want them e.g., demonstrations for customers.
i get around this issue by calling a special function just for the purpose of printing-for-debugging. that way it is easier to go remove them when things are stable and working.
i has a little set of functions i use to help with debugging. for now these are inserted instead of imported. my initial template includes them. one is dp() and it behaves like print(), except it decides to print, or not, based on an environment variable setting, and always flushes stdout after it calls the real print(). arguments are the same. another function named pv() prints out variables, their values, and whether they are local, global, or undefined. each argument for pv() is a string with a variable name. it, too, prints or not based on an environment variable. then there is zz() which works on the same environment variable conditions but pauses the program with a call to time.sleep() (after flushing stdout). zz() is useful for parts of the code that run too fast with lots of output.