I just started using VSCode a few days ago and decided to try using it for Python. A quick google search tells me that the launch.json file is where you specify commain line arguments but for the life of it, I can't get that working. It looks as if launch.json is being ignore completely.
Here's a barebones program I made:
import sys
print("testing command line args")
print(sys.argv)
And here's what my launch.json file looks like. It's pretty much what the editor generated and I just added the args parameter:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
"args": ["arg1", "arg2"]
}
]
}
And here's the output:
testing command line args
['d:\\Dev\\Python Projects\\test.py']
PS D:\Dev>
I've gone so far as to put gibberish in various launch.json parameters. It's all just being ignored. What on earth am I doing wrong?
After configuring launch.json file, you should click the run button in run and debug instead of directly clicking debug in the upper right corner of the file.