Stop at breakpoints other places when running highlighted code
Hello,
In matlab you can put a breakpoint at any point in your code/other functions etc. and if you run a highlighted piece with of code (as with shift+alt+E in pycharm) it will stop at the breakpoints, even though you're not "truly" running it in debug mode.
Is it possible to do the same in pycharm in some way?
It would be like below where I could put a breakpoint at x=x**2 and only highlight some_function(x=5, y=2) and it would still stop at the breakpoint. I'm guessing its a feature of matlab and how it reads the code (I'm not a native IT developer :)), whereas in pycharm it would cause an error and say that some_function is not defined.
some_function(x=5, y=2)
def some_function(x,y)
x=x**2
return x+y
Please sign in to leave a comment.
Unfortunately, there is no exactly the same functionality with Python, but technically you can try the following:
1. Add a breakpoint after all the imports in your script.
2. Run debug session.
3. Debugger hits a breakpoint and waits for input either from the console or from the PyCharm interface.
4. Now you can select pieces of code and choose "Execute Selection in Python Console". They will run in the debug console with all the benefits of debugging.
I hope I get the main idea right and that this will be helpful.
Thanks a lot! We'll check it out.