cf.FieldList.setattr

FieldList.setattr(attr, value)[source]

Set a named attribute on each element of the list.

fl.setattr(attr, value) is equivalent to for f in fl: f.attr = value.

Parameters:
attr : str

The attribute’s name.

value :

The value to set each attribute.

Returns:

None

See also

delattr, getattr, hasattr

Examples:
>>> fl.setattr('foo', -99)
>>> fl.getattr('foo')
[-99, -99]
>>> fl.setattr('foo', [1, 2])
>>> fl.getattr('foo')
[[1, 2], [1, 2]]

Previous topic

cf.FieldList.set_equals

Next topic

cf.FieldList.setprop

This Page