cf.List.setattr

List.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.List.method

Next topic

cf.List.append

This Page