classification
Title: Document a way to escape metacharacters in glob/fnmatch
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ezio.melotti Nosy List: docs@python, eric.araujo, ezio.melotti, fdrake, python-dev, serhiy.storchaka, terry.reedy
Priority: normal Keywords: easy

Created on 2012-10-15 14:43 by serhiy.storchaka, last changed 2012-11-17 16:05 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
fnmatch_doc_escape.patch serhiy.storchaka, 2012-10-15 14:43 review
Messages (9)
msg172976 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-10-15 14:43
fnmatch.translate's docstraing says "There is no way to quote meta-characters.", but this is wrong. One can remove the special meaning of ``'?'``, ``'*'`` and ``'['`` by wrapping them between square brackets. Thus, ``'[?]'`` matches the literal character ``'?'``.

There are a lot of related issues: issue8402, issue13929, issue9358, issue738389, issue738361, issue1580472, issue5852.
msg173771 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-10-25 17:25
I would use "It is possible to remove" rather than "One can remove", but otherwise the patch LGTM.
msg173775 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2012-10-25 17:40
Better (IMO):

Wrap the meta-characters in brackets for a literal match.  For example, ``'[?]'`` matches the character ``'?'``.
msg173779 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-10-25 17:51
My patch was only example.  Commit what you feel is better.
msg173780 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-10-25 17:55
For a literal match, wrap the meta-characters in brackets.  For example, ``'[?]'`` matches the character ``'?'``.

Stating the goal at the beginning of the sentence will make this easier to find while skimming through the doc.
msg175287 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-11-10 16:41
Ezio, feel free to finalize this.  For me all variants look good.
msg175755 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-11-17 15:39
New changeset 333fe4c4897a by Ezio Melotti in branch '2.7':
#16420: document a way to escape metacharacters in glob/fnmatch.
http://hg.python.org/cpython/rev/333fe4c4897a

New changeset 168f36c2b5ea by Ezio Melotti in branch '3.2':
#16420: document a way to escape metacharacters in glob/fnmatch.
http://hg.python.org/cpython/rev/168f36c2b5ea

New changeset 2208061d863c by Ezio Melotti in branch '3.3':
#16420: merge with 3.2.
http://hg.python.org/cpython/rev/2208061d863c

New changeset ff6d3fd9d08f by Ezio Melotti in branch 'default':
#16420: merge with 3.3.
http://hg.python.org/cpython/rev/ff6d3fd9d08f
msg175758 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-11-17 15:53
Finalized!
msg175763 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-11-17 16:05
Thank you, Ezio.  Can we now continue with issue8402?
History
Date User Action Args
2012-11-17 16:05:56serhiy.storchakasetmessages: + msg175763
2012-11-17 15:53:09ezio.melottisetstatus: open -> closed
priority: high -> normal
messages: + msg175758

assignee: docs@python -> ezio.melotti
resolution: fixed
stage: needs patch -> resolved
2012-11-17 15:50:21ezio.melottisetnosy: + python-dev
messages: + msg175755
2012-11-10 16:41:40serhiy.storchakasetkeywords: - patch

messages: + msg175287
stage: patch review -> needs patch
2012-10-25 17:55:24ezio.melottisetmessages: + msg173780
2012-10-25 17:51:37serhiy.storchakasetmessages: + msg173779
2012-10-25 17:40:13fdrakesetnosy: + fdrake
messages: + msg173775
2012-10-25 17:25:10ezio.melottisetnosy: + terry.reedy, ezio.melotti, eric.araujo

messages: + msg173771
stage: needs patch -> patch review
2012-10-24 09:23:08serhiy.storchakasettype: behavior -> enhancement
stage: needs patch
2012-10-15 14:43:29serhiy.storchakacreate