[issue18414] random.choices(seq, k)

Raymond Hettinger report at bugs.python.org
Thu Jul 11 09:21:28 CEST 2013


Raymond Hettinger added the comment:

I concur with Antoine.  A list comprehension is the standard, obvious idiom for making a list from repeated function calls.  

Putting sampling without replacement in its own method makes the operation more opaque than a plain list comprehension (which doesn't need documentation to be clear about how many calls are made, what the output type is, its relationship to random.choice, whether k can be larger than the population, etc).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18414>
_______________________________________


More information about the Python-bugs-list mailing list