On this page
glob.translate
Prev: glob.iglob | Up: glob
Rel: glob.escape, glob.glob, glob.iglob
Ref: docs.python.org — glob.translate
Tags: #public #python3 #stdlib #glob
Import
import glob
from glob import translate
Signature & Overview
glob.translate(pat, *, recursive=False, include_hidden=False, seps=None)
Translate a pathname with shell wildcards to a regular expression.
Usage
import glob
# Python 3.13+: converts glob patterns (including ** and path separators) to regex
assert hasattr(glob, "translate") or True
Gotchas
- Requires Python 3.13+: Unlike
fnmatch.translate(),glob.translate()respects/boundaries and**recursion.
REPL Inspect
from glob import translate
help(translate)
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/iglob 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