Otera.Iterable (otera v0.1.0)

Copy Markdown View Source

A Python iterable that is not a list or a tuple, with the behavior of its Python type.

type is the name of the Python type:

  • "dict_keys", "dict_values" and "dict_items", from the methods keys(), values() and items() of a dict. A view prints as dict_keys([...]), has a length, and is false when it is empty.
  • "generator", from the filters map, select, reject, selectattr, rejectattr, unique, items, batch and slice, and the reverse iterators of the reverse filter, such as "list_reverseiterator". An iterator is always true and has no length, so x|select("odd")|length raises like in Python.

A template iterates over these values like a list. Otera does not model the single pass of a Python iterator, so a template can iterate over a generator twice.

Summary

Functions

Returns true for the dict views, which have a length.

Types

t()

@type t() :: %Otera.Iterable{items: list(), type: String.t()}

Functions

view?(iterable)

@spec view?(t()) :: boolean()

Returns true for the dict views, which have a length.