mercredi 3 juin 2015

How to loop through list of options inside if statement?

I am extracting items from a subdirectory containing a mixture of files that are audio files in different formats and with different suffixes e.g. _master or _128k

I have specified higher up in the code a list of permitted extensions (e.g. ".mp3") so that I extract only files of the right formats for processing.

I also have a list (suffixExcluded) containing filename suffixes (e.g. "_syndication") I explicitly want to exclude from further processing.

How do I best write the line that effectively does:

if fileExtension in filesAllowed and [LIST OF EXCLUDED SUFFIXES] not in fileName:

... is there a neat, compact and elegant (pythonic) way of iterating through my list of exclusions within this if clause, or do I need to set up a subsidiary loop to test each item?

Thanks

Chris

Aucun commentaire:

Enregistrer un commentaire