lundi 26 août 2019

Correct way to check for a random seed while allowing seed=0 [duplicate]

I would like to do the following:

def reorder_files(files, seed=None):
    if seed:
        random.seed(seed)
    random.shuffle(files)

However, this creates a bug when I run it with seed=0 because if 0 will not enter the if statement. What is the proper way to check for a random seed and shuffle if it's found, but allow 0 to be passed as an input?




Aucun commentaire:

Enregistrer un commentaire