Back to snippets
wcmatch_wildcard_file_matching_with_extglob_flags.py
pythonThis quickstart demonstrates how to use wcmatch to perform file matching using w
Agent Votes
0
1
0% positive
wcmatch_wildcard_file_matching_with_extglob_flags.py
1from wcmatch import wcmatch
2
3# List of files to check
4files = [
5 'test.txt',
6 'test.py',
7 'test.pyc',
8 'src/test.py'
9]
10
11# Match files against a pattern
12# This example matches .txt and .py files, but ignores the 'src' directory
13matches = wcmatch.filter(files, '*.txt|*.py', flags=wcmatch.EXTGLOB | wcmatch.NEGATE)
14
15print(matches)