Skip to content

Introduction

pyparam

pypi pypi travis docs codacy quality codacy quality pyver

Powerful parameter processing

Features

  • Command line argument parser (with subcommand support)
  • list/array, dict, positional and verbose options support
  • Type overwriting for parameters
  • Rich API for Help page redefinition
  • Parameter loading from configuration files
  • Shell completions

Installation

pip install pyparam
# install latest version via poetry
git clone https://github.com/pwwang/pyparam.git
cd pyparam
poetry install

Basic usage

examples/basic.py

from pyparam import params
# define arguments
params.version      = False
params.version.desc = 'Show the version and exit.'
params.quiet        = False
params.quiet.desc   = 'Silence warnings'
params.v            = 0
# verbose option
params.v.type = 'verbose'
# alias
params.verbose = params.v
# list/array options
params.packages      = []
params.packages.desc = 'The packages to install.'
params.depends       = {}
params.depends.desc  = 'The dependencies'

print(params._parse())
> python example/basic.py
help

> python examples/basic.py -vv --quiet \
	--packages numpy pandas pyparam \
	--depends.completions 0.0.1
{'h': False, 'help': False, 'H': False,
 'v': 2, 'verbose': 2, 'version': False,
 'V': False, 'quiet': True, 'packages': ['numpy', 'pandas', 'pyparam'],
 'depends': {'completions': '0.0.1'}}

Documentation

ReadTheDocs