pyufunc.list_split_by_fixed_length#

pyufunc.list_split_by_fixed_length(lst, fixed_length)#

Split a list into sublist of the same specified length.

See also

[OPS-SL-2].

Parameters:
  • lst (list) – a list of elements

  • fixed_length (int) – the length of each sub-list

Returns:

a sequence of sub-lists

Return type:

Generator

Examples

>>> import pyufunc as uf
>>> lst = list(range(0, 10))
>>> lst
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> lst_ = uf.list_split_by_fixed_length(lst, fixed_length=3)
>>> for dat in lst_:
...     print(list(dat))
[0, 1, 2]
[3, 4, 5]
[6, 7, 8]
[9]