Re: [Python-ideas] shuffled as a way to shuffle an iterable

2016-09-08 Thread Chris Angelico
On Fri, Sep 9, 2016 at 9:36 AM, Xavier Combelle wrote: > and eventually this one work in all case of iterable > > def shuffled3(iterable): > result = list(iterable) > random.shuffle(result) > return result > This is the one obvious way to do this. Not all iterables can logically be sh

[Python-ideas] shuffled as a way to shuffle an iterable

2016-09-08 Thread Xavier Combelle
When thinking about the shuffled thread, it occurred to me that it was quite easy to pass an iterable and expect the iterable to be shuffled. but two mentioned implementation are close to success but fail by not taking this use case in account: def shuffled1(iterable): result = iterable[:]