question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to add command line arguments for terminal or in interactive window

See original GitHub issue

This 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:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
melsophoscommented, May 14, 2021

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?

0reactions
DonJayamannecommented, Dec 4, 2022

Closing this issue as there haven’t been enough upvotes on this feature request

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found