Debugging on python 2.7


(Mohmaed7777) #1

hello, world class developers ##
someone tell me about , how to debug my python code when it crash by using an optimum way of debugging to do that ,


(Stephen Cerruti) #2

In my classes my students use PyCharm, a wonderful IDE from JetBrains. I have linked to the education version, there is also a free community version. I encourage my students to register for a free student JetBrains account and make use of the full version because of the wonderful GitHub integration.

PyCharm allows them to easily debug their code setting breakpoints and evaluating variables and expressions.


(Mohmaed7777) #3

thank you so much,


(Jacopo De Stefani) #4

Alternatively, you can use the native python module pdb.
By placing a call to the function pdb.set_trace(), you can set a breakpoint in your code and spawn a python interpreter when the breakpoint is reached.


(Marcos Simental) #5

This is what I use on a daily basis as well for debugging python code.

import pdb; pdb.set_trace()

also, please consider swapping to python3 as teaching/learning python2 would not be as rewarding as python3, due to the fact that python2 is being deprecated in favor of python3: https://pythonclock.org/


(Mohmaed7777) #6

thank you so much!"