Python etc / fnmatch


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

from fnmatch import fnmatch

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

fnmatch('', '*.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.