pyvista.core._validation.check.check_iterable_items#
- check_iterable_items(
- iterable_obj,
- /,
- item_type,
- *,
- allow_subclass=True,
- name='Iterable',
Check if an iterable’s items all have a specified type.
- Parameters:
- iterable_obj
Iterable
Iterable to check.
- item_type
type
|tuple
[type
, …] Class type(s) to check for. Each element of the sequence must have the type or one of the types specified.
- allow_subclassbool, default:
True
If
True
, the type of the iterable items must be any of the given types or a subclass thereof. Otherwise, subclasses are not allowed.- name
str
, default: “Iterable” Variable name to use in the error messages if any are raised.
- iterable_obj
- Raises:
TypeError
If any of the items in the iterable have an incorrect type.
Examples
Check if a
tuple
only hasint
orfloat
elements.>>> from pyvista import _validation >>> _validation.check_iterable_items((1, 2, 3.0), (int, float))
Check if a
list
only haslist
elements.>>> from pyvista import _validation >>> _validation.check_iterable_items([[1], [2], [3]], list)