dimanche 16 mai 2021

Is there an possible way to implement compact IF-statements in my python code?

Currently I have 3 If-statements done like this:

if filetype not in filetypes:
     print(f'  SKIPPED - WRONG FILETYPE: {filetype}')
     continue
elif 'comments' in meme_url or 'gallery' in meme_url:
     print('  SKIPPED - NOT A MEME')
     continue
elif meme_id in memes or meme_id in used_memes:
     print('  SKIPPED - USED')
     continue
            

These are sorting out non-valid images and I want to be able to traceback which 'filter' worked (currently it's done via print('problem')).

Nevertheless, this code 'smells' bad, so I am interested in more intelligent solution, if there is one. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire