[issue40569] Add optional weights to random.sample()
Henk-Jaap Wagenaar
report at bugs.python.org
Sat May 9 22:39:39 EDT 2020
Henk-Jaap Wagenaar <wagenaarhenkjaap at gmail.com> added the comment:
@rhettinger: I like this proposal.
@dheiberg: to me, it seems negative weights are explicitly not supported, from: https://docs.python.org/3/library/random.html#random.choices
"Weights are assumed to be non-negative."
Unless I am missing something. In my mind negative weights make no sense and the fact it produces garbage in your example is garbage-in-garbage-out.
Maybe an enhancement could be made (but it would be breaking for some abusing the behaviour you showed) for it to error (or do something sane? If such a thing exists) but that should be a separate issue.
----------
nosy: +cryvate
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40569>
_______________________________________
More information about the Python-bugs-list
mailing list