Skip to content

Commit 2c2775b

Browse files
committed
Fix signature of random_product to: *iterables
1 parent b04b30f commit 2c2775b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Doc/library/random.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,9 +636,9 @@ or the :pypi:`more-itertools` project:
636636
.. testcode::
637637
import random
638638

639-
def random_product(*args, repeat=1):
639+
def random_product(*iterables, repeat=1):
640640
"Random selection from itertools.product(*args, **kwds)"
641-
pools = [tuple(pool) for pool in args] * repeat
641+
pools = tuple(map(tuple, iterables)) * repeat
642642
return tuple(map(random.choice, pools))
643643
644644
def random_permutation(iterable, r=None):
@@ -680,6 +680,13 @@ or the :pypi:`more-itertools` project:
680680
:hide:
681681

682682
>>> import random
683+
684+
685+
>>> random.seed(8675309)
686+
>>> random_product('ABCDEFG', repeat=5)
687+
('D', 'B', 'E', 'F', 'E')
688+
689+
683690
>>> random.seed(8675309)
684691
>>> random_derangement('')
685692
()

0 commit comments

Comments
 (0)