cf.FieldList.hasattr

FieldList.hasattr(attr)[source]

Return whether an attribute exists for each element of the list.

fl.hasattr(attr) is equivalent to cf.List(for f in fl: hasattr(f, attr)).

Parameters:
attr : str

The attribute’s name.

Returns:
out : cf.List

Whether each element has the attribute.

Examples:

See also

delattr, getattr, setattr

>>> fl.getattr('foo')
['bar1', 'bar2']
>>> del fl[1].foo
>>> fl.getattr('foo', None)
['bar1', None]

Previous topic

cf.FieldList.getprop

Next topic

cf.FieldList.hasprop

This Page