[issue37708] Harmonize random.choice(s) behavior with random.sample on iterators

2020-02-28 Thread Roundup Robot
Change by Roundup Robot : -- nosy: +python-dev nosy_count: 3.0 -> 4.0 pull_requests: +18055 pull_request: https://github.com/python/cpython/pull/18694 ___ Python tracker ___ __

[issue37708] Harmonize random.choice(s) behavior with random.sample on iterators

2019-07-31 Thread Raymond Hettinger
Raymond Hettinger added the comment: The sample() function accepts d.keys() because a keys view is registered as being an instance of collections.abc.Set. We have to do that because sample() is specifically documented as accepting sets. If we had it do over again, that functionality would

[issue37708] Harmonize random.choice(s) behavior with random.sample on iterators

2019-07-31 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: htt

[issue37708] Harmonize random.choice(s) behavior with random.sample on iterators

2019-07-29 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Seems similar to https://bugs.python.org/issue37682 -- nosy: +rhettinger, xtreak ___ Python tracker ___ ___

[issue37708] Harmonize random.choice(s) behavior with random.sample on iterators

2019-07-29 Thread Lex Flagel
New submission from Lex Flagel : It would be nice to make random.sample and random.choice both have the same behavior with iterators. Currently random.sample accepts them happily, and whereas random.choice does not. E.g. > import random > d = {'a':1, 'b':2} > random.sample(d.keys(),1) Out: [