Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ordered-argparse

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ordered-argparse

Modified version of argparse which remembers the order of CLI arguments

  • 1.0.10
  • PyPI
  • Socket score

Maintainers
1

ordered_argparse

Version of Python's standard library's argparse which also remembers the order of command line arguments.

Installation

Install with pip install ordered_argparse.

Usage

Create an instance of ArgumentParser as usual. Use namespace=ordered_argparse.OrderedNamespace(). Access arguments in declaration order by calling parser's .ordered() method.

import ordered_argparse

parser = ordered_argparse.ArgumentParser()
parser.add_argument("--foo", action="store_true", help="foo")
parser.add_argument("--bar", action="store_true", help="bar")

# Use OrderedNamespace when parsing CLI arguments
args = parser.parse_args(["--foo", "--bar"], namespace=ordered_argparse.OrderedNamespace())

# Access ordered arguments by calling .ordered()
for arg in args.ordered():
    print(f"{arg}")

Compatibility with argcomplete

ordered_argparse only works with argcomplete as long as you don't use subparsers. If you use subparsers, you need ordered_argcomplete.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc