is_valid_list
- dtaianomaly.utils.is_valid_list(value, target_type) bool[source]
Check if a given list is valid.
Check if the given list is a valid, with each instance being a member of the given type.
- Parameters:
- valueobject
The value to check if it is a valid list.
- target_typeType
The type of each object in the given list.
- Returns:
- bool
True if and only if the given
valueis a list and all elements in the list are of typeType, otherwise False.
Examples
>>> from dtaianomaly.utils import is_valid_list >>> is_valid_list([1, 2, 3, 4, 5], int) True >>> is_valid_list([1, 2, 3, 4, 5], str) False >>> is_valid_list(["1", "2", "3", "4", "5"], int) False >>> is_valid_list(["1", "2", "3", "4", "5"], str) True