cf.List.method

List.method(callable_method, *args, **kwargs)[source]

Return an list of the results of a method applied to each element.

fl.method(name, *args, **kwargs) is equivalent to cf.List(f.name(*args, **kwargs) for f in fl).

Parameters:
name : str

The name of the method to apply to each element.

args, kwargs : optional

The arguments to be used in the call to the named method.

Returns:
out : cf.List

The results of the named method applied to each element.

See also

iter

Examples:
>>> x = cf,List(['a, 'b', 'c'])
>>> x.method('upper)
['A, 'B', 'C']
>>> x.method('find', 'a')
[0, -1, -1]
>>> x
['a, 'b', 'c']
>>> x = cf.List([[3, 2, 1], [6, 5, 4]])
>>> x.method('sort')
[None, None, None]
>>> x
[[1, 2, 3], [4, 5, 6]]

Previous topic

cf.List.iter

Next topic

cf.List.setattr

This Page