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 serhiy.storchaka
Recipients NeilGirdhar, aisaac, madison.may, mark.dickinson, pitrou, rhettinger, serhiy.storchaka, tim.peters, westley.martinez
Date 2013-09-24.21:26:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Most existing implementation produce just index. That is why weighted_choice() accepts singular weights list and returns index. On the other hand, I think working with mapping will be wished feature too (especially because Counter is in stdlib). Indexable sequences and mappings are similar. In both cases weighted_choice() returns value which can be used as index/key of input argument.

If you need choice an element from some sequence, just use seq[weighted_choice(weights)]. Actually weighted_choice() has no common code with choice() and has too different use cases. They should be dissimilar as far as possible. Perhaps we even should avoid the "choice" part in function names (are there any ideas?) to accent this.
Date User Action Args
2013-09-24 21:26:04serhiy.storchakasetrecipients: + serhiy.storchaka, tim.peters, rhettinger, mark.dickinson, pitrou, aisaac, westley.martinez, NeilGirdhar, madison.may
2013-09-24 21:26:04serhiy.storchakasetmessageid: <>
2013-09-24 21:26:04serhiy.storchakalinkissue18844 messages
2013-09-24 21:26:04serhiy.storchakacreate