Pycharm: Is there a way to save a break point state and debug going forward?
Asked Answered
I

3

11

When debugging a code in Pycharm is there a way to save current state before proceeding forward? That way I do not have to re-process everything that was already debugged if there is a bug downstream.

Thanks

Intercollegiate answered 15/8, 2018 at 13:20 Comment(0)
B
3

While you can create a temporary debug template to make it easier to get back to the point you're at, it is not possible to save the entire state of a running debug session and modify code downstream. My only suggestion would be to run a new instance of your script and keep the debug open for the current session as it is.

Beldam answered 15/8, 2018 at 15:23 Comment(1)
Thanks ... I am too used to the convenience of notebooks (am a data scientist) ... but when I take code out of there and am turning it into "real code" .. I miss the ability to just work on a cell -- without rerunning everything upstream if I something bugs out.Intercollegiate
A
3

Based on your comment to the "correct" answer, it sound like what you really want is the interactiveness, which you can easily have in PyCharm in multiple ways.

Through debugger: One way is to set a break point, and then start executing code in the console from this state. You can execute a large selection of code or just one line at the time.

Without debugger: Another option is to just use the Python console to execute code interactively. Also here you can execute a large selection of code or one line at a time.

Astilbe answered 20/11, 2020 at 9:15 Comment(0)
C
0

When debugging a code in Pycharm is there a way to save current state before proceeding forward? That way I do not have to re-process everything that was already debugged if there is a bug downstream.

This is not about PyCharm, but about the Python application itself.

  • PyCharm is an editor and Python is the virtual machine running the code - you are really asking if Python VM can save a state
  • If the application crashes in a certain point, but not before that you can save the application state within the application itself
  • A common way to save the application state is e.g. to write files on a disk
  • There is no generic solution to save an application state, because an application may have open files, network sockets and such that are independent, external factors, for the application and these cannot be recovered without having the logic in place in the application itself
Chilpancingo answered 3/6 at 7:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.