mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
GH-102653: Make recipe docstring show the correct distribution (#102742)
This commit is contained in:
parent
a297d59609
commit
b0ec6253c9
1 changed files with 2 additions and 1 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue