Minor fix for currentframe (SF #1652788).
[python.git] / Doc / lib / libfnmatch.tex
blobfc4b97a3126ab9488c27b819f9f12b4875094b45
1 \section{\module{fnmatch} ---
2 \UNIX{} filename pattern matching}
4 \declaremodule{standard}{fnmatch}
5 \modulesynopsis{\UNIX\ shell style filename pattern matching.}
8 \index{filenames!wildcard expansion}
10 This module provides support for \UNIX{} shell-style wildcards, which
11 are \emph{not} the same as regular expressions (which are documented
12 in the \refmodule{re}\refstmodindex{re} module). The special
13 characters used in shell-style wildcards are:
15 \begin{tableii}{c|l}{code}{Pattern}{Meaning}
16 \lineii{*}{matches everything}
17 \lineii{?}{matches any single character}
18 \lineii{[\var{seq}]}{matches any character in \var{seq}}
19 \lineii{[!\var{seq}]}{matches any character not in \var{seq}}
20 \end{tableii}
22 Note that the filename separator (\code{'/'} on \UNIX) is \emph{not}
23 special to this module. See module
24 \refmodule{glob}\refstmodindex{glob} for pathname expansion
25 (\refmodule{glob} uses \function{fnmatch()} to match pathname
26 segments). Similarly, filenames starting with a period are
27 not special for this module, and are matched by the \code{*} and
28 \code{?} patterns.
31 \begin{funcdesc}{fnmatch}{filename, pattern}
32 Test whether the \var{filename} string matches the \var{pattern}
33 string, returning true or false. If the operating system is
34 case-insensitive, then both parameters will be normalized to all
35 lower- or upper-case before the comparison is performed. If you
36 require a case-sensitive comparison regardless of whether that's
37 standard for your operating system, use \function{fnmatchcase()}
38 instead.
39 \end{funcdesc}
41 \begin{funcdesc}{fnmatchcase}{filename, pattern}
42 Test whether \var{filename} matches \var{pattern}, returning true or
43 false; the comparison is case-sensitive.
44 \end{funcdesc}
46 \begin{funcdesc}{filter}{names, pattern}
47 Return the subset of the list of \var{names} that match \var{pattern}.
48 It is the same as \code{[n for n in names if fnmatch(n, pattern)]}, but
49 implemented more efficiently.
50 \versionadded{2.2}
51 \end{funcdesc}
53 \begin{seealso}
54 \seemodule{glob}{\UNIX{} shell-style path expansion.}
55 \end{seealso}