is_all_same#

openstef_core.utils.itertools.is_all_same(items: Iterable) bool[source]#

Check that all items have the same value.

Note

This function requires that the items are hashable and comparable for equality. For unhashable types, consider converting to a list and comparing manually.

Returns:

True if all items in the iterable are equal, False otherwise. Returns False for empty iterables (no items to be equal).

Return type:

bool

Example

>>> is_all_same([1, 1, 1, 1])
True
>>> is_all_same([1, 2, 1])
False
>>> is_all_same(['a', 'a', 'a'])
True
>>> is_all_same([])
False
Parameters:

items (Iterable[TypeVar(T)])

Return type:

bool