Reload code in debug mode

Answered

Hi!

I'd like to know if there's a way to edit the code while debugging. Suppose the line that I want to change is not reached, like this

Here I'd like to change line 4 to, say, "b = 1 / (a + 1)" and then continue to debug, without restarting.

I heard that there's workaround with importlib.reload(), is there an easy way to reload module in the current frame? Or any other solution?

Thank you!

0
3 comments
Avatar
Permanently deleted user

Thanks, Sergey!

Still haven't found a way to reload a debugger, but now I know it's currently not implemented in Pycharm. Surprised that this feature has so few votes ;(

0

You can try my PyCharm plugin Reloadium that adds hot reloading ( aka edit and continue) to any python application.

https://github.com/reloadware/reloadium

https://plugins.jetbrains.com/plugin/18509-reloadium

If you have objects in your code that you don't wan't to reload you might need to wrap them with # reloadium: no_reload as described here:

https://reloadium.io/documentation/decorators

1

Please sign in to leave a comment.