euporie.core.layout.containers.take_using_weights
- euporie.core.layout.containers.take_using_weights(items: list[_T], weights: list[int]) Generator[_T, None, None]
Generator that keeps yielding items from the items list, in proportion to their weight. For instance:
# Getting the first 70 items from this generator should have yielded 10 # times A, 20 times B and 40 times C, all distributed equally.. take_using_weights(['A', 'B', 'C'], [5, 10, 20])
- Parameters:
items – List of items to take from.
weights – Integers representing the weight. (Numbers have to be integers, not floats.)