Skip to main content

easy cooperation between main-function and argparse

Project description

Overview

The wonderparse project allows for easy cooperation between a main-function/an object that hold the central functions on the one side and argparse on the other.

Installation

To install wonderparse, you can use pip. Open your terminal and run:

pip install wonderparse

Usage

The code from the expit project.

import math as _math

import wonderparse as _wp


def function(x:float):
    try:
        p = _math.exp(-x)
    except OverflowError:
        p = float('+inf')
    return 1 / (1 + p)

def main(args=None):
    _wp.easymode.simple_run(
        args=args,
        program_object=function,
        prog='expit',
    )

Working example:

main([".4"])
### 0.598687660112452

Example with missing parameter.

main([])
### usage: expit [-h] x
### expit: error: the following arguments are required: x
### An exception has occurred, use %tb to see the full traceback.

Example with faulty typing.

main(["spam"])
### usage: expit [-h] x
### expit: error: argument x: invalid float value: 'spam'
### An exception has occurred, use %tb to see the full traceback.

The wonderparse project allows for parsing made easy.

License

This project is licensed under the MIT License.

Credits

Thank you for using wonderparse!

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

wonderparse-1.4.1.tar.gz (8.1 kB view hashes)

Uploaded Source

Built Distribution

wonderparse-1.4.1-py3-none-any.whl (10.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page