Python Forum
what do YOU use to debug Python code you write? an IDE?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what do YOU use to debug Python code you write? an IDE?
#11
I use print statements all the time.
sometimes with, sometimes without a debug conditional attached.
But I really think that having watches available is a huge help.
So more often than not, I use the debugger.
Reply
#12
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.
Reply
#13
(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.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#14
Wrong result? Two reasons. Wrong or improperly formatted input data or wrong script logic. You can control the first but the second one...  We learn best from our mistakes, right? If there were no mistakes, we would not be able to learn. ;)
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#15
yeah, for you do want to fix the code, i assume.  you do want to know that code is doing wrong, i assume.

errors like an index out of range on line 83 may really be a mistake in line 67.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020