Coding

argparse – parser for command-line options, arguments and sub-commands

The argparse module makes it easy to write user-friendly command-line interfaces. The program defines what arguments it requires, and argparse will figure out how to parse those out of sys.argv.

The argparse module also automatically generates help and usage messages and issues errors when users give the program invalid arguments.

argparse is the “recommended command-line parsing module in the Python standard library.” It’s what you use to get command line arguments into your program. As of Python >= 2.7 and >= 3.2, the argparse module is maintained within the Python standard library.

The argparse module was added to Python 2.7 as a replacement for optparse.

Key Features

  • Handles both optional and positional arguments.
  • Produces highly informative usage messages.
  • Supports parsers that dispatch to sub-parsers.

Website: docs.python.org
Support:
Developer: Steven Bethard, Thomas Waldmann
License: Python Software Foundation License

argparse is written in Python. Learn Python with our recommended free books and free tutorials.


Related Software

Command-Line Python Application Development Tools
Python FireLibrary for automatically generating command line interfaces
argparseParser for command-line options, arguments and sub-commands
ClickCreate beautiful command line interfaces in a composable way
TyperLibrary for building CLI applications
RichPython library for rich text and beautiful formatting
GooeyConvert console programs into end-user-friendly GUI software
alive-progressProgress bar, with real-time throughput
Python Prompt ToolkitBuild powerful interactive command line and terminal applications
tqdmFast, extensible progress bar for Python and CLI
AsciimaticsCreate full-screen text UIs from interactive forms to ASCII animations
CementCLI application framework for Python
docoptCommand-line interface description language
cliffFramework for building command line programs

Read our verdict in the software roundup.


Best Free and Open Source Software Explore our comprehensive directory of recommended free and open source software. Our carefully curated collection spans every major software category.

This directory is part of our ongoing series of informative articles for Linux enthusiasts. It features hundreds of detailed reviews, along with open source alternatives to proprietary solutions from major corporations such as Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk.

You’ll also find interesting projects to try, hardware coverage, free programming books and tutorials, and much more.

Discovered a useful open source Linux program that we haven’t covered yet? Let us know by completing this form.
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments