Given the following piece of python code:
for root, dirs, files in os.walk(directory): for filename in fnmatch.filter(files, \'*.png\'): pass
If you only need to check extensions (i.e. no further wildcards), why don't you simply use basic string operations?
for root, dirs, files in os.walk(directory): for filename in files: if filename.endswith(('.jpg', '.jpeg', '.gif', '.png')): pass