Is it possible to change the code while debugging in VSCode and that the change will take effect immediately without rerun the code? I'm using Microsoft Python extension.
Asked
Active
Viewed 3,665 times
17
-
1I don't think that's possible in any language. You can change code while a program is running, but you still have to re-run the code to see the change. – Mar 19 '19 at 14:20
-
3In vba it's possible. – Adirmola Mar 19 '19 at 14:27
-
@Adirmola But generally not in other languages. – BoarGules Mar 19 '19 at 14:49
-
4Too bad. I really don't understand why not, it's a big advantage in debugging. – Adirmola Mar 19 '19 at 16:28
-
Yeah, that would be a nice feature. Seems like Eclipse IDE can do it with [Java](https://stackoverflow.com/questions/12661114/how-to-modify-java-code-while-running-in-debug-mode/12661165#12661165) and [Python](https://stackoverflow.com/questions/23333815/is-there-edit-and-continue-in-pycharm-reload-code-into-running-program-like-i). – wisbucky Aug 31 '21 at 18:03
2 Answers
1
It depends. There's no such thing as a hot reload in Python. The closest you can come is importlib.reload()
, but realize that only reloads the module and not the objects which already exist in memory. IOW it typically doesn't do what you want in code (it's usually used in the REPL).

Brett Cannon
- 14,438
- 3
- 45
- 40
1
So, apparently that the closest way of doing it is to use Jupyter capabilities (that can be use via VSCode).
With Jupyter you can split your code to multiple cells and run every each one of them separately without run all from beginning.

Adirmola
- 783
- 5
- 15