rest25/library/fnmatch.rst => rest262/library/fnmatch.rst
38.. function:: fnmatch(filename, pattern)
39
40   Test whether the *filename* string matches the *pattern* string, returning true
41   or false.  If the operating system is case-insensitive, then both parameters
42   will be normalized to all lower- or upper-case before the comparison is
43   performed.  If you require a case-sensitive comparison regardless of whether
44   that's standard for your operating system, use :func:`fnmatchcase` instead.
45
n46+   This example will print all file names in the current directory with the
47+   extension ``.txt``::
48+ 
49+      import fnmatch
50+      import os
51+ 
52+      for file in os.listdir('.'):
53+          if fnmatch.fnmatch(file, '*.txt'):
54+              print file
55+ 
46
47.. function:: fnmatchcase(filename, pattern)
48
49   Test whether *filename* matches *pattern*, returning true or false; the
50   comparison is case-sensitive.
51
52
53.. function:: filter(names, pattern)
54
55   Return the subset of the list of *names* that match *pattern*. It is the same as
56   ``[n for n in names if fnmatch(n, pattern)]``, but implemented more efficiently.
57
58   .. versionadded:: 2.2
59
60
t71+.. function:: translate(pattern)
72+ 
73+   Return the shell-style *pattern* converted to a regular expression.
74+ 
75+   Example:
76+ 
77+      >>> import fnmatch, re
78+      >>>
79+      >>> regex = fnmatch.translate('*.txt')
80+      >>> regex
81+      '.*\\.txt$'
82+      >>> reobj = re.compile(regex)
83+      >>> print reobj.match('foobar.txt')
84+      <_sre.SRE_Match object at 0x...>
85+ 
86+ 
61.. seealso::
62
63   Module :mod:`glob`
64      Unix shell-style path expansion.
65
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op