Top "Argparse" questions

A Python module for implementing command-line interfaces

Parsing boolean values with argparse

I would like to use argparse to parse boolean command-line arguments written as "--foo True" or "--foo False". For example: …

python boolean argparse command-line-parsing
How can I pass a list as a command-line argument with argparse?

I am trying to pass a list as an argument to a command line program. Is there an argparse option …

python argparse
Simple argparse example wanted: 1 argument, 3 results

The documentation for the argparse python module, while excellent I'm sure, is too much for my tiny beginner brain to …

python argparse
Argparse optional positional arguments?

I have a script which is meant to be used like this: usage: installer.py dir [-h] [-v] dir is …

python argparse
Argparse: Required arguments listed under "optional arguments"?

I use the following simple code to parse some arguments; note that one of them is required. Unfortunately, when the …

python argparse
Python argparse command line flags without arguments

How do I add an optional flag to my command line args? eg. so I can write python myprog.py …

python command-line-arguments argparse
Python argparse: default value or specified value

I would like to have a optional argument that will default to a value if only the flag is present …

python default-value argparse
Display help message with python argparse when script is called without any arguments

This might be a simple one. Assume I have a program that uses argparse to process command line arguments/options. …

python argparse
Check if argparse optional argument is set or not

I would like to check whether an optional argparse argument has been set by the user or not. Can I …

python argparse
Why use argparse rather than optparse?

I noticed that the Python 2.7 documentation includes yet another command-line parsing module. In addition to getopt and optparse we now …

python command-line optparse getopt argparse