use SystemRandom for randomshuffle instead of own rolled implementation
This commit is contained in:
parent
3ca05e2390
commit
183e6491d0
@ -1,13 +1,6 @@
|
||||
import secrets
|
||||
from random import SystemRandom
|
||||
|
||||
def random_shuffle(theList):
|
||||
myList = list(theList)
|
||||
shuffledList = []
|
||||
myListLength = len(myList) + 1
|
||||
while myListLength > 0:
|
||||
removed = secrets.randbelow(myListLength)
|
||||
try:
|
||||
shuffledList.append(myList.pop(removed))
|
||||
except IndexError:
|
||||
pass
|
||||
myListLength = len(myList)
|
||||
return shuffledList
|
||||
SystemRandom().shuffle(myList)
|
||||
return myList
|
Loading…
Reference in New Issue
Block a user