diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-11-18 11:06:43 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-11-18 11:06:43 (GMT) |
commit | fd32fffa5ada8b8be8a65bd51b001d989f99a3d3 (patch) | |
tree | 2b0324a2068af8e9b1d887bb74b426ac9f12ca2b /Doc/library/glob.rst | |
parent | e3010fd740b63df306f878fc872e29d5f6be7487 (diff) | |
download | cpython-fd32fffa5ada8b8be8a65bd51b001d989f99a3d3.zip cpython-fd32fffa5ada8b8be8a65bd51b001d989f99a3d3.tar.gz cpython-fd32fffa5ada8b8be8a65bd51b001d989f99a3d3.tar.bz2 |
Issue #8402: Added the escape() function to the glob module.
Diffstat (limited to 'Doc/library/glob.rst')
-rw-r--r-- | Doc/library/glob.rst | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Doc/library/glob.rst b/Doc/library/glob.rst index eff138b..57ccf4a 100644 --- a/Doc/library/glob.rst +++ b/Doc/library/glob.rst @@ -40,6 +40,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 |