docs: def weighted_random_choice(items):
      """
      Returns a weighted random choice from a list of items.
      :param items: A list of tuples (object, weight)
      :return: A random object, whose likelihood is proportional to its weight.
      """
      l = list(items)
      r = random.random() * sum([i[1] for i in l])
      for x, p in l:
          if p > r:
              return x
          r -= p
      return None