I'm working on a project that depends on a big library that takes a long time to load. I use VSCode and I'm looking for a workflow that doesn't import this library each time I need to execute my code to check the results.
I think that executing the current file in the VSCode Python REPL is probably the best way to do this. For now, the best I can do is to select all my code (ctrl a), then execute it in on the repl (shift enter), which is a bit tedious.
Is there a way to get this behavior by just pressing f5 or another unique key?
If you choose "Python / Dynamic Python: File" that will execute the file that you have open in the editor.
It is also possible to edit the .vscode/launch.json
file for more advanced scenarios.
CodePudding user response:
Add the magic command #%%
above your code, Then you will get a jupyter-like interface.
select Run Cell or other run mode, and an interactive window will open.
Or right-click directly in the code file and select Run Current File in Interactive Window
You can also add a shortcut key for this action: