Let’s use again the code showed on the previous entrance (connect to MS Access using Python), to show you how to debug code using PyScripter. As you can see in the next image, there is an icon to start the debugging process, or you can press F7 (you cann’t do it with F8, that goes to the next line).
After the debug process begin, a blue line is where the code is running. Also, in the down area you can find the Python interpreter, and you can see how the promtp has changed to include [Dbg], indicating you are in debug mode.

Debug Python code
Let’s go further by pressing F8 (or F7) until you arrive to line 12. Let’s move to the interpreter to verify what’s the value of a variable, by using print sql:
Even I can modify the value of variables using the interpreter:
Another choice is to verify the value of a variable by locating the cursos on the variable on the code:
This way, you can know what’s the value of the variable, also the type, and of course, you can notice that the value is the new value given on the interpreter to the sql variable.
Now, let’s go inside a funcion by pressing F7 (F8 move to next line):
By pressing F8 you execute line by line the query function of the MSAccessConnector class, and after finishing, you come back to the code. You can press Shift+F8 if you don’t want to run a funcion line by line, and you want the debug process to finish at the end of the function.
After running the rest of the code, you can see the outcome is using the modified value on the interpreter.
Algunas cosas que no se pueden hacer al depurar
Con los antecedentes que tengo a nivel de programación, me quedo con la forma que tiene Visual Basic 6 o VBA de depurar, donde puedes arrastrar el punto de ejecución para adelante y para atrás (aquí no está permitido!).
Tampoco puedes modificar código sobre la marcha, otro punto importante de VB6 y VBA tampoco disponible en Python (ni en C#).
How to debug is very important
How to Debug is one of the action when creating code that every developer must take care of. Here I’ve written using PyScripter, one of the IDEs I normally use for coding Python, but the process is similar in other IDEs.
I hope you will read this entrance carefully for a better coding!