Skip to main content

functions while mapping and validating dynamic

Project description

argscall

argscall is python library that can be used to call functions while mapping and validating dynamic input arguments «*args or **kwargs» using the function arguments signature.

Usage

from argscall import argsCaller

# A simple function that requires one argument
def do_something(name):
    print(name.upper())

# Call the function passing a list with arguments
argscall(do_something, "a").call()

It becomes more usefull when used with dynamic input arguments, e.g command line arguments:

# test.py
import sys
from argscall import argsCaller


# A sample function that requires an argument
def do_something(name):
    print(name.upper())


# Call the function passing the command line arguments
argsCaller(do_something, *sys.argv[1:]).call()

Testing different use cases

$ python test.py Joe
JOE

$ python test.py
Traceback (most recent call last)
...
argscall.exceptions.MissingArgument: Missing required argument: name


$ python test.py Joe Black
Traceback (most recent call last)
...
argscall.exceptions.TooManyArgument: Got more arguments than expected (value: 'Black')

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

argscall-0.0.2.tar.gz (7.1 kB view hashes)

Uploaded Source

Built Distribution

argscall-0.0.2-py3-none-any.whl (7.1 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