Ability to add command line arguments for terminal or in interactive window
See original GitHub issueThis is related to bug microsoft/vscode-python#11206 which is currently addressed with a workaround. and specifically this comment https://github.com/microsoft/vscode-python/issues/11206#issuecomment-615393463
To summarize here:
Currently, using argparse fails (crashes) in the Interactive Window. A workaround is to run sys.argv = ['']
.
It would be helpful if we could provide command line arguments which are taken into account when running in the terminal, debugging and in the interactive window. These should be stored per file, not per project, since a single project could have multiple files which are run, each with different arguments.
test code:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--test', default='Hello')
args = parser.parse_args()
print(vars(args))
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Windows Terminal command line arguments | Microsoft Learn
Learn how to create command line arguments for Windows Terminal. ... The wt command line accepts two types of values: options and commands....
Read more >Python Command Line Arguments
Adding the capability of processing Python command line arguments provides a user-friendly interface to your text-based command line program.
Read more >How do I pass command line arguments to Python from VS in ...
Go to debug mode in VS Code · Click on the settings icon (gear icon). If it does not exist this will create...
Read more >Integrated Terminal in Visual Studio Code
Use the Ctrl+Shift+` keyboard shortcut to create a new terminal. Use the View > Terminal or Terminal > New Terminal menu commands. From...
Read more >Executing functions with multiple arguments at a terminal in ...
Example 2 : This program demonstrates how command line arguments are passed into a function using sys.argv[index]. The command line arguments at ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In-between, I have a question on the workaround: is there any way to say that
sys.argv = ['']
must be executed only in the interactive window, and not when the file is executed directly with python?Closing this issue as there haven’t been enough upvotes on this feature request