Skip to main content

An automatic handling of parameter passing to python programs.

Project description


An automatic handling of parameter passing to python programs


Import the script. Then in the top of your own document, define a list of tuples of all your parameters of the form ('name', 'prefix'/position, type), and then call the library using params.params(Your_Parameters). This will return a dictionary of all the parameters of the form {'name' : value}.

The library supports prefixed parameters (i.e. whatever comes after '-i'), boolean parameters (i.e. if '-a' is passed) and positional parameters (i.e. the second parameter without a prefix).

Currently supported types are str, int, float and bool. Multi-word parameters must be enclosed in quotes.


import params

parameters = [('output', '-o', str),   # A string parameter with prefix '-o'
              ('amount', '-n', int),   # An integer parameter with prefix '-n'
              ('verbose', '-v', bool), # A boolean parameter with name '-v'
              ('eggs', '-e', float),   # A float parameter with prefix '-e'
              ('input', 0, str),       # A string parameter position 0
              ('spam', 1, int),        # An integer parameter position 1
              ('message', '-m', str)]  # A string parameter with prefix '-m'

p = (params.params(parameters))


Then calling the program with the parameters as such: python -v gov_secrets.db -o elvis.mp3 4 -n 10 -m "Listen to this cool track!", will result in the following output:

{'output': 'elvis.mp3',
 'amount': 10,
 'verbose': True,
 'eggs': None,
 'input': 'gov_secrets.db',
 'spam': 4,
 'message': 'Listen to this cool track!'}


  • Add default values

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for parapy, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size parapy-0.0.3-py3-none-any.whl (14.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size parapy-0.0.3.tar.gz (2.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page