On this page
  1. fnmatch.translate
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

fnmatch.translate

Prev: fnmatch.fnmatchcase | Up: fnmatch
Rel: fnmatch.filter, fnmatch.filterfalse, fnmatch.fnmatch, fnmatch.fnmatchcase
Ref: docs.python.org — fnmatch.translate
Tags: #public #python3 #stdlib #fnmatch


Import

import fnmatch
from fnmatch import translate

Signature & Overview

fnmatch.translate(pat)

Translate a shell PATTERN to a regular expression.

Usage

import fnmatch
import re

regex = fnmatch.translate("*.py")
assert re.match(regex, "main.py") is not None

Gotchas

REPL Inspect

from fnmatch import translate
help(translate)

Linked from

Related notes