This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Christian.Kleineidam
Recipients Christian.Kleineidam, NeilGirdhar, aisaac, dkorchem, madison.may, mark.dickinson, pitrou, rhettinger, serhiy.storchaka, tim.peters, westley.martinez
Date 2014-09-15.00:39:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1410741545.53.0.592121367622.issue18844@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2014-09-15 00:39:05Christian.Kleineidamsetrecipients: + Christian.Kleineidam, tim.peters, rhettinger, mark.dickinson, pitrou, aisaac, westley.martinez, serhiy.storchaka, NeilGirdhar, madison.may, dkorchem
2014-09-15 00:39:05Christian.Kleineidamsetmessageid: <1410741545.53.0.592121367622.issue18844@psf.upfronthosting.co.za>
2014-09-15 00:39:05Christian.Kleineidamlinkissue18844 messages
2014-09-15 00:39:04Christian.Kleineidamcreate