On this page
glob.iglob
Prev: glob.glob | Up: glob | Next: glob.translate
Rel: glob.escape, glob.glob, glob.translate
Ref: docs.python.org — glob.iglob
Tags: #public #python3 #stdlib #glob
Import
import glob
from glob import iglob
Signature & Overview
glob.iglob(pathname, *, root_dir=None, dir_fd=None, recursive=False, include_hidden=False)
Return an iterator which yields the paths matching a pathname pattern.
Usage
import glob
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as tmp:
(Path(tmp) / "x.md").write_text("# hi")
matches = list(glob.iglob(str(Path(tmp) / "*.md")))
assert len(matches) == 1
Gotchas
- Lazy iterator counterpart to
glob.glob(): Better memory footprint on large directory trees.
REPL Inspect
from glob import iglob
help(iglob)
Linked from
Related notes
- tuts/python3/stdlib_module/glob/escape Linked here; links to this page; shared tags: #glob, #stdlib
- tuts/python3/stdlib_module/glob/glob Linked here; links to this page; shared tags: #glob, #stdlib
- tuts/python3/stdlib_module/glob/translate Linked here; links to this page; shared tags: #glob, #stdlib
- tuts/python3/stdlib_module/glob links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib