pytilities.overloading.parameter — Pytilities v1.0.0 documentation

### Navigation

- index
- modules |
- next |
- previous |
- Pytilities v1.0.0 documentation »
- API documentation »
- pytilities »
- pytilities.overloading »

# pytilities.overloading.parameter

`pytilities.overloading.parameter.` `Param`

  alias of `Parameter`

class `pytilities.overloading.parameter.` `Parameter`(name, *args, **kwargs)

  A parameter of an operation.

  It can match arguments and provide default values for them.

  Note that an argument matches a parameter, if its matcher returns True on the argument value or the parameter has a default.

  `__init__`(name, *args, **kwargs)

    Construct a Parameter.

    Parameters: | name (string) – name of parameter as specified in keyword arguments kwargs – Keyword parameters: type_ or types or matcher: type_: type of the parameter types: iterable of possible types for the parameter matcher: a matcher function of type f(value) -> matched::bool If given as first positional arg, type_ is assumed. If not given, will match any value. default: default value for the parameter. Omit if param has no default Can also be given as second positional arg.
    Preconditions : | default must match the specified matcher

  `__str__`()
  `read_arg`(arg)

    Read/process the given arg.

    Parameters: | arg – the argument value to read
    Returns: | True if parameter matches arg
    Return type: | bool

  `read_kwargs`(kwargs)

    Look in a dict for a matching arg and process its value.

    Parameters: | kwargs – frozen dictionary of arguments
    Returns: | True if a matching argument was found in kwargs
    Return type: | bool

  `write`(kwargs)

    Adds the last read argument value to a dictionary.

    Parameters: | kwargs – the dictionary to add the last value and the parameter name to
    Preconditions : | the parameter matched on the last read

  `__weakref__`

    list of weak references to the object (if defined)

  `_matched`
  `name`

### Navigation

- index
- modules |
- next |
- previous |
- Pytilities v1.0.0 documentation »
- API documentation »
- pytilities »
- pytilities.overloading »