Package pytilities :: Package overloading :: Module compositeparameter :: Class CompositeParameter
[hide private]
[frames] | no frames]

Class CompositeParameter

source code

         object --+    
                  |    
parameter.Parameter --+
                      |
                     CompositeParameter

Parameter that consists of more parameters.

This parameter matches lists, tuples and dicts, of which all elements match the list of child parameters.

When this parameter is written to a dict, its child parameters are expanded. E.g. for a composite parameter with childs 'x' and 'y', a read value of (1, 3) and a dict d of {}; after writing to d, d will equal {x:1, y:3}, and not {{x:1, y:3}}.

Methods:

Instance Methods [hide private]
 
__init__(self, name, params, matcher=(<type 'tuple'>, <type 'list'>, <type 'dict'>), *args, **kwargs)
Construct a CompositeParameter.
source code
 
__match(self, value) source code
 
write(self, kwargs)
Adds the last read argument value to a dictionary.
source code

Inherited from parameter.Parameter: read_arg, read_kwargs

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from parameter.Parameter (private): _matched

Inherited from object: __class__

Method Details [hide private]

__init__(self, name, params, matcher=(<type 'tuple'>, <type 'list'>, <type 'dict'>), *args, **kwargs)
(Constructor)

source code 

Construct a CompositeParameter.

Parameters:

name :: string
name of the parameter, used for keyword arguments. Must be unique.
params :: (Parameter...)
the child parameters of the composite
matcher :: f(value) -> matched::bool
:: (type...) = (tuple, list, dict) :: type

the parameter will match only if this matcher matches the arg and its child args match the elements of the arg. It is unlikely you'll need a value other than the default.

default
default value for the parameter, omit if param has no default
Overrides: object.__init__

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:

  1. the parameter matched on the last read
Overrides: parameter.Parameter.write
(inherited documentation)