Save the date! Google I/O returns May 18-20 Register now

Returns a list of files that match the given pattern(s).

Used in the notebooks

Used in the tutorials

The patterns are defined as strings. Supported patterns are defined here. Note that the pattern can be a Python iteratable of string patterns.

The format definition of the pattern is:

pattern: { term }


  • '*': matches any sequence of non-'/' characters
  • '?': matches a single non-'/' character
  • '[' [ '^' ] { match-list } ']': matches any single character (not) on the list
  • c: matches character c where c != '*', '?', '\\', '['
  • '\\' c: matches character c

character range:

  • c: matches character c while c != '\\', '-', ']'
  • '\\' c: matches character c
  • lo '-' hi: matches character c for lo <= c <= hi

# For example, ['']"__init__.??")
# As above
files = {"*.py"}
the_iterator = iter(files)
# As above

See the C++ function GetMatchingPaths in core/platform/file_system.h for implementation details.

pattern string or iterable of strings. The glob pattern(s).

A list of strings containing filenames that match the given pattern(s).

errors.OpError If there are filesystem / directory listing errors.
errors.NotFoundError If pattern to be matched is an invalid directory.