-2

Python has the flag -i, that allows interacting with the script after executing it in the terminal, e.g. python script.py -i. Usually how I do this is in VC Code

  1. Run the script with "the play button"
  2. Add "-i" to the terminal command and run again

Obviously this is not ideal, so I was wondering if there is a way do this with a single command or a way perhaps add more options under "the play button" menu where you can switch between running the script and debugging.

I'm also aware of the interactive mode, but that requires installing IPython and I don't want to go that way.

Tzane
  • 2,752
  • 1
  • 10
  • 21
  • 1
    answer is alrady avilable here: https://stackoverflow.com/questions/40036942/running-a-python-program-with-arguments-from-within-the-visual-studio-code – Muhammad Zakaria Jul 01 '22 at 12:02
  • @MuhammadZakaria Based on what I see on the [docs for launch,json](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations) I don't think it is possible to do, in addition to my understanding launch.json is only used by the debugger – Tzane Jul 01 '22 at 12:15

1 Answers1

0

At present, vscode can adjust the command. The only official support of vscode is to use "launch.json" to set the command during debugging.

Of course, if you want to be supported at runtime, you can try using code-runner.

It has the function of customizing commands:

{
"code-runner.customCommand": "echo Hello"

}

MingJie-MSFT
  • 5,569
  • 1
  • 2
  • 13