Skip to main content

Python argument design patterns in a composable interface.

Project description

python-args, inspired by attrs, removes the boilerplate of processing arguments to functions and methods.

Decorating your functions with python-args decorators like arg.validators can make your code more composable, more readable, and easier to test. Along with this, functions decorated with python-args can be used to by other tools and frameworks to build more expressive interfaces. The django-args and django-action-framework libraries are two examples.

The core python-args decorators are as follows:

  1. @arg.validators(*validation_funcs): Runs validation functions that can take the same named arguments as the decorated function. When decorating a function with arg.validators, you not only de-couple your function from argument validation logic, but python-args will allow other interfaces to only run the validators of your function.

  2. @arg.defaults(**arg_default_funcs): Sets arguments to default values. The default functions can similarly take the same named parameters of the decorated function.

  3. @arg.parametrize(**parametrize_funcs): Runs a function multiple times for a particular input.

  4. @arg.contexts(*context_funcs): Enters context managers before a function. Context managers can take the same named parameters as the decorated function.

View the docs here for a tutorial and more examples of how python-args can be used in practice.


View the python-args docs here.


Install python-args with:

pip3 install python-args

Contributing Guide

For information on setting up python-args for development and contributing changes, view CONTRIBUTING.rst.

Primary Authors

  • @wesleykendall (Wes Kendall)

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

python-args-1.0.2.tar.gz (12.3 kB view hashes)

Uploaded source

Built Distribution

python_args-1.0.2-py3-none-any.whl (12.1 kB view hashes)

Uploaded py3

Supported by

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