les_iterables.generating module

Summary

Functions:

generate

A decorator factory to make a generator return a fully realised collection.

one

Yield an iterable series of one item.

Reference

les_iterables.generating.one(item)[source]

Yield an iterable series of one item.

Parameters:

item – The item to be yielded.

Yields:

An iterable series of a single item.

les_iterables.generating.generate(collection=None)[source]

A decorator factory to make a generator return a fully realised collection.

Some functions are easier to write as generator functions, even though we don’t want the lazy behaviour of generators. Use this decorator to fully consume a generator into a collection.

Parameters:

collection – The collection type to be realised. The default of nothing causes this decorator to do nothing. Normall a collection type such as a list, set or tuple is provided.

Returns:

A decorator function which decorates a function with a wrapper which fully evaluates the wrapped generator function, and uses it to create a collection.