Skip to content

Commit

Permalink
pythonGH-102653: Make recipe docstring show the correct distribution (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
rhettinger authored Mar 16, 2023
1 parent a297d59 commit b0ec625
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Doc/library/random.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit b0ec625

Please sign in to comment.