cfdm.core.Container._get_component

Container._get_component(component, default=ValueError())[source]

Return a component.

New in version (cfdm): 1.7.0

Parameters
component:

The name of the component to be returned.

default: optional

Return default if the component has not been set.

If set to an Exception instance then it will be raised instead.

Returns

The component. If unset then default is returned, if provided.

Examples

>>> f = cfdm.core.Container()
>>> f._set_component('foo', 'bar')
>>> f._has_component('foo')
True
>>> f._get_component('foo')
'bar'
>>> f._del_component('foo')
'bar'
>>> f._has_component('foo')
False