cf.FieldList.getattr

FieldList.getattr(attr, *default)[source]

Get a named attribute from each element of the list.

fl.getattr(attr, *default) is equivalent to cf.List(for f in fl: getattr(f, attr, *default)).

Parameters :
attr : str

The attribute’s name.

default : optional

When a default argument is given, it is returned when the attribute doesn’t exist; without it, an exception is raised in that case.

Returns :
out : cf.List

Each element’s attribute value.

Examples

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

Previous topic

cf.FieldList.flip

Next topic

cf.FieldList.getprop

This Page