Issue #18844: Make the number of selections a keyword-only argument for random.choices().

This commit is contained in:
Raymond Hettinger 2016-09-26 21:45:57 -07:00
parent 22805ca54e
commit 9016f2864a
4 changed files with 27 additions and 23 deletions

View file

@ -337,7 +337,7 @@ class Random(_random.Random):
result[i] = population[j]
return result
def choices(self, k, population, weights=None, *, cum_weights=None):
def choices(self, population, weights=None, *, cum_weights=None, k=1):
"""Return a k sized list of population elements chosen with replacement.
If the relative weights or cumulative weights are not specified,