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

Class Arguments


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.

Method Summary
  __init__(self, fmt_args)
Compile an argument list to positional and keyword argument formats
  check(self, args, kwargs)
Check arguments
  _checkarg(self, fmt, arg, nameorpos)
Check for an argument, sends a TypeError Exception if arguments doesn't accomplish constraint
  _expand(self, fmt)
Expands a format to an entity usable by isinstance or None

Class Variable Summary
dict Types = {'c': <type 'complex'>, 'b': <type 'bool'>, 'd':...

Method Details

__init__(self, fmt_args)
(Constructor)

Compile an argument list to positional and keyword argument formats

check(self, args=(), kwargs={})

Check arguments

_checkarg(self, fmt, arg, nameorpos)

Check for an argument, sends a TypeError Exception if arguments doesn't accomplish constraint

_expand(self, fmt)

Expands a format to an entity usable by isinstance or None

Class Variable Details

Types

Type:
dict
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'>,
...                                                                    

Generated by Epydoc 2.1 on Sat Oct 14 11:50:52 2006 http://epydoc.sf.net