glob — Easy Examples
Unix-style pathname pattern expansion (wildcards like *.txt)
Getting started with glob
Basic import and usage of the glob module.
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).
Common glob operations
Frequently used functions from the glob module.
python
# More glob examples import glob print(f"glob module loaded successfully") print(f"Location: {glob.__name__}") print(f"Has {len(dir(glob))} attributes")
These are the most commonly used features of the glob module.
Want to try these examples interactively?
Open Easy Playground