Alias argument decorator

This section discusses the purpose of the @alias_argument decorator, shows how to use it and provides reference documentation.

Purpose

This decorator allows a function to accept a range of parameters names, to make the interface easier to use for the end-user.

from climetlab.decorators import alias_argument


@alias_argument(param="parameter")
def func(param, other):
    return "param=" + param


func(param="tp", other=1)
# -> param=tp

func(parameter="tp", other=1)
# -> param=tp

The decorator also accept a list of alias values.

from climetlab.decorators import alias_argument


@alias_argument(param=["parameter", "variable"])
def func(param, other=1):
    return "param=" + param


func(param="tp")
# -> param=tp

func(parameter="tp")
# -> param=tp

func(variable="tp")
# -> param=tp