pyvista.DataSetAttributes.get

pyvista.DataSetAttributes.get#

DataSetAttributes.get(
key: str,
value: Any | None = None,
) pyvista_ndarray | None[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.

valueAny, 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 as pv
>>> mesh = pv.Cube()
>>> mesh.point_data['my_data'] = range(mesh.n_points)
>>> mesh.point_data.get('my-other-data')