For the complete documentation index, see llms.txt. This page is also available as Markdown.

collections

Starlark module for working with collections library.

This module implements specialized container datatypes providing alternatives to Python's general purpose built-in containers, dict, list, set, and tuple.

Similar to collections in Python.

collections.after_each(separator, iterable)

Inserts separator after each item in iterable.

Parameters:

  • separator - the value to insert after each item in iterable.

  • iterable - the list into which to intersperse the separator.

Returns: a new list with separator after each item in iterable.

collections.before_each(separator, iterable)

Inserts separator before each item in iterable.

Parameters:

  • separator - the value to insert before each item in iterable.

  • iterable - the list into which to intersperse the separator.

Returns: a new list with separator before each item in iterable.

collections.namedtuple(typename, field_names, rename=False, defaults=None, module=None)

Returns: a new subclass of tuple with named fields.

Examples:

collections.uniq(iterable)

Returns: a list of unique elements in iterable. Requires all the elements to be hashable.

Parameters:

iterable – an iterable to filter.

Returns: a new list with all unique elements from iterable.

Last updated