I use Anaconda Spyder (version 5.2.2) to debug my Python codes. My codes contain some .py programs that should be executed serially. I use a single routine that executes these codes using the exec() method [exec(open("Python_Code.py").read())]. However, it seems that the debugger ignores breakpoints located inside the codes. To reproduce this issue, save the following simple code in a .py file, e.g., Python_Code.py.
# Python_Code.py file
a = 1
b = 2
Now run the following code:
# Main routine
c = 3
exec(open("Python_Code.py").read())
d = 4
Breakpoints outside the Python_Code.py work, but the debugger does not stop at Breakpoints inside this code. I think it is because all reading and execution of the entire code are regarded as a single function; hence it is not possible to put breakpoints inside the code. If this is the case, is there any way to debug this code by putting breakpoints inside them and then executing these codes serially in a single routine? In summary, I need a way of debugging codes run by calling them, e.g., using the exec() method.
I searched the web. I expect a way of debugging codes run by calling them, e.g., using the exec() method.