Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

command line arguments in python debugging

# In vscode you need to click on the screw in the debugging sidepanel.
# It will open up a json file with some text already written there.
# Example:
# Let's say I have a script named script.py
# which takes 2 arguments, path to file and a boolean verbose

# Normally we would write something like this in the terminal:
# python script.py --filename=foo.txt --verbose
# In the json, you pass them in a list as follows:
"args": ["--filename", "foo.txt", "--verbose"]
# Notice that you drop the "=" and
# write --filename and foo.txt as separate list entries
Comment

command line arguments in python debugging

The steps are shown in the image linked here:

https://i.stack.imgur.com/Hx5tf.png

Go to debug mode in VS Code
Click on the settings icon (gear icon). If it does not exist this will create a launch.json
In the json, in any of the configuration, add the args json parameter:
{
    "name": "Python: Terminal (integrated)",
    "type": "python",
    "request": "launch",
    "stopOnEntry": true,
    "pythonPath": "${config:python.pythonPath}",
    "program": "${file}",
    "cwd": "",
    "console": "integratedTerminal",
    "env": {},
    "args": [
        "input2.csv",
        "output2.csv"
    ],
    "envFile": "${workspaceFolder}/.env",
    "debugOptions": [],
    "internalConsoleOptions": "neverOpen"
}
Comment

PREVIOUS NEXT
Code Example
Python :: Looping and counting in python 
Python :: merge 2 dataframes in python 
Python :: add icon to exe file 
Python :: python min key 
Python :: identity matrix python 
Python :: pandas remove whitespace 
Python :: tkinter simple application 
Python :: pyautogui doc 
Python :: append a dataframe to an empty dataframe 
Python :: uppercase python 
Python :: pygame bg color 
Python :: python A string float numeral into integer 
Python :: get files in directory 
Python :: else if python 
Python :: python pickle module 
Python :: numpy evenly spaced numbers 
Python :: create python package 
Python :: Concat Sort codechef solution 
Python :: select rows with multiple conditions pandas query 
Python :: Find the length of a nested list in python 
Python :: stack program in python3 
Python :: sorting decimal numbers in python 
Python :: how to import a class from a file to another python 
Python :: AI chatbot in Python - NAYCode.com 
Python :: is python a scripting language 
Python :: cholesky decomposition in python 
Python :: pandas read csv file 
Python :: choose value none in pandas 
Python :: concatenate list 
Python :: python breadth first search 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =