[issue33098] add implicit conversion for random.choice() on a dict

2018-03-19 Thread Aristide Grange
Aristide Grange added the comment: My bad... For my reference to Python 2, I relied on my memory only, which starts to vanish. Really sorry about that. Yes, `random.choice(d)` (mostly) fails in Python 2 too, with an error message that I better understand after

[issue33098] add implicit conversion for random.choice() on a dict

2018-03-18 Thread Tim Peters
Tim Peters added the comment: This won't be changed. The dict type doesn't support efficient random choice (neither do sets, by the way), and it's been repeatedly decided that it would do a disservice to users to hide that. As you know, you can materialize the keys in a

[issue33098] add implicit conversion for random.choice() on a dict

2018-03-18 Thread Aristide Grange
New submission from Aristide Grange : In Python 3, the expression: ```python random.choice(d) ``` where `d` is a `dict`, raises this error: ``` ~/anaconda3/lib/python3.6/random.py in choice(self, seq) 256 except ValueError: 257 raise