pytilities.overloading.parameter.Parameter

Package pytilities :: Package overloading :: Module parameter :: Class Parameter |
[hide private]
[frames] | no frames]

# Class Parameter

source code

    object --+
             |
            Parameter

Known Subclasses:
  - compositeparameter.CompositeParameter

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.

Methods:

> - read_arg: Read/process the given arg.
> - read_kwargs: Look in a dict for a matching arg and process its value
> - write: Adds the last read argument value to a dictionary.

Instance Methods | [hide private]
__init__(self, name, matcher=<function matches_everything at 0x1745398>, *args, **kwargs) Construct a Parameter. | source code
read_arg(self, arg) Read/process the given arg. | source code
read_kwargs(self, kwargs) Look in a dict for a matching arg and process its value. | source code
write(self, kwargs) Adds the last read argument value to a dictionary. | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties | [hide private]
| _matched
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, name, matcher=<function matches_everything at 0x1745398>, *args, **kwargs) (Constructor) | source code
Construct a Parameter. Parameters: `name` :: string name of parameter as specified in keyword arguments `matcher` :: Either of: type of the parameter iterable of possible types of param a matcher function :: f(value) -> matched::bool `default` default value for the parameter. Omit if param has no default Preconditions: `default` must match the specified matcher Overrides: object.__init__

### read_arg(self, arg) | source code
Read/process the given arg. Parameters: `arg` the argument value to read Returns True if parameter matches `arg` :: bool

### read_kwargs(self, kwargs) | source code
Look in a dict for a matching arg and process its value. Parameters: `kwargs` :: {name::string : value} dictionary of arguments Returns True if a matching argument was found in `kwargs` :: bool

### write(self, kwargs) | source code
Adds the last read argument value to a dictionary. Parameters: `kwargs` :: {name::string : value} the dictionary to add the last value and the parameter name to Preconditions: the parameter matched on the last read

Property Details | [hide private]

### _matched Get Method: unreachable._matched(self)