Christian Kleineidam added the comment:

I like the idea of adding a weights keyword to choice and creating an 
additional choice_generator() that also takes weights.

A choice_generator() could take a further argument to allow unique choices and 
be a generator version of sample().

In some cases you want to draw randomly from a sequence till you draw an item 
that fulfills certain criteria. At the moment neither the sample nor the 
shuffle method seems to be optimal for that use case.

Given that items are commonly drawn from an urn in math, urn seems a good 
alternative for choice_generator().

random.urn(data, *, weights=None, unique=False)

----------
nosy: +Christian.Kleineidam

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18844>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to