-h/--help arg to program instead shows help for interpreter
See original GitHub issueEnvironment data
- VS Code version: 1.27.2
- Extension version (available under the Extensions sidebar): 2018.8.0
- OS and version: Windows 10 (1709)
- Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.0
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): N/A
- Relevant/affected Python packages and their versions: N/A
Actual behavior
my-file.py contains:
import argparse
version = '1.0.0'
def main():
arg_parser = argparse.ArgumentParser(description='Foo')
try:
args = arg_parser.parse_args()
except Exception as e:
traceback.print_exc()
exit(1)
exit(0)
if __name__ == '__main__':
main()
launch.json contains:
{
"name": "Python: Current File - help arg",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": [
"--help" // or "-h"
]
},
Outputs the help for the python interpreter:
cd <my-workspace-path> && cmd /C "set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" && set "PYTHONPATH=c:\Users\<username>\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd" && python -m ptvsd --host localhost --port 60918 <my-file-path>.py --help "
usage:
python.exe -m ptvsd [-h] [-V] [--nodebug] [--host HOST | --server-host HOST] --port PORT -m MODULE [arg ...]
python.exe -m ptvsd [-h] [-V] [--nodebug] [--host HOST | --server-host HOST] --port PORT FILENAME [arg ...]
positional arguments:
filename
optional arguments:
-h, --help show this help message and exit
--nodebug
--host HOST
--server-host SERVER_HOST
--port PORT
-m MODULE
--single-session
-V, --version show program's version number and exit
Then after some ten seconds or so, shows an error like:
[Window Title] Visual Studio Code
[Content] Timeout waiting for debugger connection
[Open launch.json] [Cancel]
Expected behavior
Evaluate the help arg as an argument to my file, i.e. respond with my file’s response to the -h arg
Steps to reproduce:
- create a python script that handles -h and --help args
- add a configuration to
launch.json
to call the script with one of these args - launch using the created configuration
- check the output
Logs
No logs created
Other arguments appear to work as intended.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Why doesn't python use its own argparse library for its associated ...
The python module has argparse to pass command-line arguments. ... it call the interpreted argparse Python code before starting the Python interpreter?
Read more >2. Using the Python Interpreter — Python 3.11.1 documentation
A second way of starting the interpreter is python -c command [arg] ... , which executes the statement(s) in command, analogous to the...
Read more >Interpreter Files
where pathname is the path of the interpreter and arg is a single ... The following example shows how to create and execute...
Read more >Interpreter Rules of Conduct | Judicial Administration
As officers of the court, interpreters help assure that such persons ... Verbal and non-verbal displays of personal attitudes, prejudices, ...
Read more >Foundations of Interpretation Curriculum Content Narrative
by a philosophy that charges interpreters to help audiences care about park ... he became concerned about the quality of interpretive programs in...
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
ptvsd uses Python’s argparse.py: to leave arguments unparsed, precede them with the
"--"
argument. Thus, the launch.json should be:Reference: https://stackoverflow.com/a/9084137/1329652
@ruyman-vfx nothing is planned to support passing arguments to
ptvsd_launcher.py
as there shouldn’t be anything you need there which isn’t provided as an argument inlaunch.json
.