Re: Reading a random element from a set

2017-07-26 Thread Peter Otten
ast wrote: > Hello > > random.choice on a set doesn't work because sets are > not indexable > > so I found nothing better than taking an element and > puting it back > > a = {5, 7, 8, 3, 0, 8, 1, 15, 16, 34, 765443} > elt = a.pop() > a.add(elt) > > any better idea, in a single instruction ?

Re: Reading a random element from a set

2017-07-26 Thread ast
"Steven D'Aprano" a écrit dans le message de news:597841eb$0$2878$c3e8da3$76491...@news.astraweb.com... On Wed, 26 Jul 2017 08:58:03 +0200, ast wrote: Hello random.choice on a set doesn't work because sets are not indexable so I found nothing better

Re: Reading a random element from a set

2017-07-26 Thread Steven D'Aprano
On Wed, 26 Jul 2017 08:58:03 +0200, ast wrote: > Hello > > random.choice on a set doesn't work because sets are not indexable > > so I found nothing better than taking an element and puting it back > > a = {5, 7, 8, 3, 0, 8, 1, 15, 16, 34, 765443} > elt = a.pop() > a.add(elt) That's not

Reading a random element from a set

2017-07-26 Thread ast
Hello random.choice on a set doesn't work because sets are not indexable so I found nothing better than taking an element and puting it back a = {5, 7, 8, 3, 0, 8, 1, 15, 16, 34, 765443} elt = a.pop() a.add(elt) any better idea, in a single instruction ? --