The zaqar.common.storage.select module

select: a collection of algorithms for choosing an entry from a collection.

weighted(objs, key=’weight’, generator=<bound method Random.randint of <random.Random object at 0x11a0e00>>)

Perform a weighted select given a list of objects.

Parameters:
  • objs ([dict]) – a list of objects containing at least the field key
  • key (six.text_type) – the field in each obj that corresponds to weight
  • generator (function(int, int) -> int) – a number generator taking two ints
Returns:

an object

Return type:

dict