Package SPyRO :: Module args :: Class Arguments
[hide private]
[frames] | no frames]

Class Arguments

source code


Check if the arguments are valid against |fmt_args|.
If any constraint is not valid, the function
will return raise a TypeError and will set the appropiate string in the
raised Exception.

If the number of the given arguments are lesser that supposed
it will raise TypeError too

A proper check of arguments inside functions can be performed using
the function 'local()' to retrieve local variables. And get the
retrieve arguments

|fmt_args| is a collection of tuples (argument_name, argument_value)

Example
( ('arg1',fmt_arg1),
  ('arg2',fmt_arg2),
  ('arg3',fmt_arg3),
  ...
)

The arguments will be create two checking instances a list and a
dictionary. The list checks positional arguments |args|, then when
positional arguments are
exhausted, named arguments |kwargs| will be checked with the dictionary
validator.



Instance Methods [hide private]
 
__init__(self, fmt_args)
Compile an argument list to positional and keyword argument formats
source code
 
_expand(self, fmt)
Expands a format to an entity usable by isinstance or None
source code
 
_checkarg(self, fmt, arg, nameorpos)
Check for an argument, sends a TypeError Exception if arguments doesn't accomplish constraint
source code
 
check(self, args=(), kwargs={})
Check arguments
source code
Class Variables [hide private]
  Types = {'b': <type 'bool'>, 'c': <type 'complex'>, 'd': <type...
Class Variable Details [hide private]

Types

Value:
{'b': <type 'bool'>,
 'c': <type 'complex'>,
 'd': <type 'dict'>,
 'f': <type 'float'>,
 'i': <type 'int'>,
 'l': <type 'list'>,
 'n': <type 'NoneType'>,
 'o': <type 'instance'>,
...