diff options
Diffstat (limited to 'Doc/library/glob.rst')
-rw-r--r-- | Doc/library/glob.rst | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Doc/library/glob.rst b/Doc/library/glob.rst index eff138b..abcbf38 100644 --- a/Doc/library/glob.rst +++ b/Doc/library/glob.rst @@ -25,6 +25,10 @@ For a literal match, wrap the meta-characters in brackets. For example, ``'[?]'`` matches the character ``'?'``. +.. seealso:: + The :mod:`pathlib` module offers high-level path objects. + + .. function:: glob(pathname) Return a possibly-empty list of path names that match *pathname*, which must be @@ -40,6 +44,17 @@ For example, ``'[?]'`` matches the character ``'?'``. without actually storing them all simultaneously. +.. function:: escape(pathname) + + Escape all special characters (``'?'``, ``'*'`` and ``'['``). + This is useful if you want to match an arbitrary literal string that may + have special characters in it. Special characters in drive/UNC + sharepoints are not escaped, e.g. on Windows + ``escape('//?/c:/Quo vadis?.txt')`` returns ``'//?/c:/Quo vadis[?].txt'``. + + .. versionadded:: 3.4 + + For example, consider a directory containing only the following files: :file:`1.gif`, :file:`2.txt`, and :file:`card.gif`. :func:`glob` will produce the following results. Notice how any leading components of the path are |