mercredi 18 mars 2020

Python random.choice always selects first value

AUDIO_FILES = [
    os.path.join(settings.AUDIO_FILES_DIR, "1.mp3"),
    os.path.join(settings.AUDIO_FILES_DIR, "2.mp3"),
    os.path.join(settings.AUDIO_FILES_DIR, "3.mp3"),
    os.path.join(settings.AUDIO_FILES_DIR, "4.mp3"),
    os.path.join(settings.AUDIO_FILES_DIR, "5.mp3"),
]

def _get_audio_clip():
    audio_file = random.choice(AUDIO_FILES)
    audio_clip = AudioFileClip(audio_file)
    return audio_clip

Can anyone point out why random.choice always returns first value of the list in this piece of code?




Aucun commentaire:

Enregistrer un commentaire