python runtime warning debugging

Question:

I am trying to learn Python, and I am still a novice so please bear with me. I am using the Komodo IDE environment. I currently wish to debug a a runtime warning that says:

RuntimeWarning: invalid value encountered in greater & (matrixCsvOutput[:,8] > 30))[0] ,:]

Now, I wish to set a breakpoint that would allow me to examine the composition of “matrixCsvOutput” at runtime. I expect that the value in question may be a null or a nan, and therefore fail the operation.

My question is: how can I set the debugger to break when the runtime error occurs? Many thanks in advance!

Asked By: aag

||

Answers:

before the line number mentioned in RuntimeWarning, add this:

import pdb ; pdb.set_trace()
Answered By: johntellsall

You can run your script through pdb from the command line too:

python -m pdb myscript.py

(command taken from the pdb docs)

Answered By: daniel

To anyone (but probably not novice) who concerns only debugging the runtime warnings, you may find this post helpful.

Answered By: Ray