Python etc / fnmatch

fnmatch

Module fnmatch provides a few functions to work with Unix-like patterns:

from fnmatch import fnmatch

fnmatch('example.py', '*.py')
# True

fnmatch('example.py', '*.cpp')
# False

Internally, it parses the given pattern and compiles it into a regular expression. So, don't expect it to be faster than re. Also, if you want to match actual files in the filesystem, use pathlib.Path.glob instead.