[issue17470] random.choice should accept a set as input
Mark Dickinson added the comment: See also issue #7522 (with an identical title!) for previous discussion. -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17470 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17470] random.choice should accept a set as input
New submission from Mohammad Akram: I think the random.choice function should support sets. The random.sample function already supports sets and therefore the API should be consistent in this regard. This is how it's done in the sample method (line 295): if isinstance(population, _Set): population = tuple(population) -- components: Library (Lib) messages: 184532 nosy: Mohammad.Akram priority: normal severity: normal status: open title: random.choice should accept a set as input type: enhancement versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17470 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17470] random.choice should accept a set as input
Changes by Jason Ward jason.louard.w...@gmail.com: -- keywords: +patch Added file: http://bugs.python.org/file29471/17470.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17470 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17470] random.choice should accept a set as input
R. David Murray added the comment: Choice is a very simple function. If it supported sets, it would have to convert the set to a sequence *each time* choice was called. It is probably better to leave this as a task for the user of choice to perform. Sample, on the other hand, does quite a bit of work after doing the conversion, and one is somewhat less likely to call it multiple times on the same input. I'm not going to close the issue, since my argument here speaks to the implementation rather than the API, so I'm not entirely comfortable with it. I'll let Raymond decide :). -- nosy: +r.david.murray, rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17470 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17470] random.choice should accept a set as input
Changes by Jason Ward jason.louard.w...@gmail.com: -- nosy: +Jason.Ward ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17470 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17470] random.choice should accept a set as input
Raymond Hettinger added the comment: Sorry Mohammad, I concur with David Murray's reasoning. -- resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17470 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com