You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by larsoner April 29, 2021
The way I have used Python for years (through Spyder, directly from a bash terminal, etc.) is to execute a script in interactive mode such that once it's done, you can interact with it, e.g.:
python -i script.py
VSCode's debugger does not give a way to get this behavior currently. And it seems like I am not the only one looking for it:
One workaround is to put a breakpoint at the end of your file, but this requires extra work.
Another workaround is to add "env": {"PYTHONINSPECT": "true"}, to the launch configuration with integratedTerminal, but this doesn't work properly as any input is captured and newlines aren't treated properly while printing, which makes it pretty unusable.
I could see at least two potential solutions (the first would be better I think):
Make it so that in PYTHONINSPECT mode, the terminal could be interacted with properly, possibly by adding a new inspectOnExit or something that ran in -i / PYTHONINSPECT mode and returned proper input/output when the script completes. Based on Python Debugger - using python in interactive mode via PYTHONINSPECT vscode-python#5497 it sounds like this is a no-go, though.
Add a stopOnExit debug option to mirror stopOnEntry in the debugger. This way at least variables could be inspected using the vscode debugger.
Discussed in microsoft/vscode-python#16082
Originally posted by larsoner April 29, 2021
The way I have used Python for years (through Spyder, directly from a bash terminal, etc.) is to execute a script in interactive mode such that once it's done, you can interact with it, e.g.:
VSCode's debugger does not give a way to get this behavior currently. And it seems like I am not the only one looking for it:
One workaround is to put a breakpoint at the end of your file, but this requires extra work.
Another workaround is to add
"env": {"PYTHONINSPECT": "true"},to the launch configuration withintegratedTerminal, but this doesn't work properly as any input is captured and newlines aren't treated properly while printing, which makes it pretty unusable.I could see at least two potential solutions (the first would be better I think):
PYTHONINSPECTmode, the terminal could be interacted with properly, possibly by adding a newinspectOnExitor something that ran in-i/PYTHONINSPECTmode and returned proper input/output when the script completes. Based on Python Debugger - using python in interactive mode via PYTHONINSPECT vscode-python#5497 it sounds like this is a no-go, though.stopOnExitdebug option to mirrorstopOnEntryin the debugger. This way at least variables could be inspected using the vscode debugger.