get#

DataSetAttributes.get(key: str, value: Optional[Any] = None) Optional[pyvista_ndarray][source]#

Return the value of the item with the specified key.

Parameters
keystr

Name of the array item you want to return the value from.

valueanything, optional

A value to return if the key does not exist. Default is None.

Returns
Any

Array if the key exists in the dataset, otherwise value.

Examples

Show that the default return value for a non-existent key is None.

>>> import pyvista
>>> mesh = pyvista.Cube()
>>> mesh.point_data['my_data'] = range(mesh.n_points)
>>> mesh.point_data.get('my-other-data')