GH-102653: Make recipe docstring show the correct distribution (#102742)

This commit is contained in:
Raymond Hettinger 2023-03-16 09:32:18 -05:00 committed by GitHub
parent a297d59609
commit b0ec6253c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -610,7 +610,8 @@ from the combinatoric iterators in the :mod:`itertools` module:
return tuple(pool[i] for i in indices)
def random_combination_with_replacement(iterable, r):
"Random selection from itertools.combinations_with_replacement(iterable, r)"
"Choose r elements with replacement. Order the result to match the iterable."
# Result will be in set(itertools.combinations_with_replacement(iterable, r)).
pool = tuple(iterable)
n = len(pool)
indices = sorted(random.choices(range(n), k=r))