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.

Source Distribution

parapy-0.0.3.tar.gz (2.4 kB view hashes)

Uploaded source

Built Distribution

parapy-0.0.3-py3-none-any.whl (14.9 kB view hashes)

Uploaded py3

Supported by

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