glob exclude pattern | ExceptionsHub
exceptionshub.com › glob-exclude-patternJan 29, 2018 · Answers: More generally, to exclude files that don’t comply with some shell regexp, you could use module fnmatch: import fnmatch file_list = glob ('somepath') for ind, ii in enumerate (file_list): if not fnmatch.fnmatch (ii, 'bash_regexp_with_exclude'): file_list.pop (ind) The above will first generate a list from a given path and next pop ...
glob exclude pattern
https://newbedev.com/glob-exclude-patternYou can't exclude patterns with the glob function, globs only allow for inclusion patterns. Globbing syntax is very limited (even a [!..] character class must match a character, so it is an inclusion pattern for every character that is not in the class).