glob

Stdlib — OS/FilePython 2.0+Beginner

Unix-style pathname pattern expansion (wildcards like *.txt)

Quick Info

Documentation
Official Docs
Python Version
2.0+
Dependencies
None — Python Standard Library
Install
Included with Python

Learn by Difficulty

Quick Example

python
# glob - file pattern matching
print("glob finds files matching patterns:")
print("  glob.glob('*.py')")
print("  glob.glob('**/*.txt', recursive=True)")

import fnmatch
print(fnmatch.fnmatch("hello.py", "*.py"))
print(fnmatch.fnmatch("test.txt", "*.py"))

The glob module is part of Python's standard library. Unix-style pathname pattern expansion (wildcards like *.txt).

Try in Playground

Tags

stdlibfile-iopatternwildcard

Related Items