7

I know that some languages, like .NET (I have some experience doing this on Visual Studio), there is a way to stop the execution on a break points and change the nexts lines of code, change value of variables or even change the execution line without reloading the application.

This is pretty usefull, since you can write your code while it's executing, specilly for non linear codes, where some functions are called in events, like django or flask aplications.

I would like to know if there is a way (if possible using vscode) to do the same in python.

0

1 Answer 1

4

Yes, you need to add this in the launch.json file:

"autoReload": {
    "enable": true
}

You can refer to the official docs for more information.

Sign up to request clarification or add additional context in comments.

2 Comments

Note that what this perform is simply an auto-reload on debug point hitting or on save. This means that all files are re-loaded, and it can trigger code not included in an if __name__ == “__main__” statement. This also mean that if your debug point is within an if __name__ == “__main__” block, the hot reload won't work there; it will work only for code outside it. Still, better than nothing.
Also, I'm adding that this feature is completely flawed. It seems to only work in limited scenarios, where you only modify the content of a line of code, but you cannot add or remove lines of code from a function, otherwise it uses the old copy of the function. I haven't tested much, but its limitedness and unreliability makes it an unusable for me (like most of Python and its ecosystem, actually).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.