Skip to main content

Parameter Parser (Python)

Parameter Parser is a simple library used to parse intricate parameters from an array of strings.

Hint: This package is available through Python PIP. pip install parameterparser

Supports Python 2.7+

PyPI version PyCodeStyle Downloads GitHub issues PyPI - License

Documentation - Advanced Code Examples - Looking for the PHP version?

Features

  • Parse command line parameters.
  • Assign aliases to parameters.
  • Custom closures for each command line parameter.
  • Variadic closure support for arguments taking more than one value.
  • Customize the way the command line is parsed.

Example Usage

import sys
from parameterparser import Parameter, Cluster, Parser

# Initialize a new Cluster
parameters = Cluster()

# Add a Parameter to the Cluster
parameter = Parameter("-", "name", lambda name: name)

parameter.set_required(True)\
         .set_description("Your name.")

parameters.add(parameter)

# Create a new Parser using the Cluster
parser = Parser(sys.argv, parameters)

# Parse the parameters using the Parser.
results = parser.parse()

# Verify that the parameters were valid after parsing.
if not parser.is_valid():
    # Since it was not valid, output usage.
    parameters.print_full_usage(
        "Parameter Parser",
        "An advanced parameter parser for Python",
        "v1.0.0"
    )
else:
    # Retrieve the name from the results
    name = results['name']

    # Output the name
    print("Your name is " + name + os.linesep)

Output

~/ python test.py -name 'Nathan Fiscaletti'

   Your name is Nathan Fiscaletti

Development

Before commiting anything, please create a pre-commit hook with the following content.

This will ensure that the pycodestyle badge is properly updated.

#!/bin/bash
python3 tests/style.py

Metadata

Release files for parameterparser 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for parameterparser 0.1.7
File Size Uploaded
parameterparser-0.1.7.tar.gz 9.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for parameterparser 0.1.7
File Interpreter ABI Platform
parameterparser-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 20.6 kB

Release files / parameterparser-0.1.7.tar.gz

Download URL parameterparser-0.1.7.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
82dd0c1c5ebe66753e2f7462f3516f366bb6cfaf18614cc3e44b1331a2ab17bb
BLAKE2b-256 checksum
How to use checksums
60766c7202edd328131a6739e0720b7ef4b92b6cf7fe6ceae1f5564a027bb53f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.4

Release files / parameterparser-0.1.7-py3-none-any.whl

Download URL parameterparser-0.1.7-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1084457295b9e06f47cc1f0c51323a81e7b8a5867427a8536a76ff2583b0497
BLAKE2b-256 checksum
How to use checksums
320e3b2a532184aded3b0d5aec9d1914a1e98a48999688698deffcee59ac028b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.4

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page