Utility Classes :: IsAllOf

Overview

The IsAllOf class is used to specify that the object must meet all of any number of criterion, e.g., be an instance of certain types or user-defined classes, or be validated by other extension classes [1].

The IsAllOf() constructor must be passed at least two ([2]) distinct ([3]) types, user-defined classes or registered extension classes. For example:

@accepts(int, int, IsAllOf(Red, Green))
def my_func(a, b, c):
    pass

The following code snippet matches the signature:

class Christmas_tree(Red, Green):
	pass

oh_tannenbaum = Christmas_tree()

my_func(3, 3, oh_tannenbaum)

The requirement that there are two distinct conditions stems from the fact that the following call is almost certainly an error:

IsAllOf(Red, Red)

Details

References

  1. test_utility_classes.py: Test_And.test_success
  2. test_utility_classes.py: Test_And.test_constructor
  3. test_utility_classes.py: Test_And.test_distinct_parameters
  4. test_utility_classes.py: Test_And.test_failure
  5. test_utility_classes.py: Test_And.test_equality
  6. test_utility_classes.py: Test_And.test_hash

Valid XHTML 1.0 Transitional