This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients fruch, terry.reedy
Date 2012-02-04.04:41:10
SpamBayes Score 6.423086e-07
Marked as misclassified No
Message-id <1328330472.06.0.296320613225.issue13929@psf.upfronthosting.co.za>
In-reply-to
Content
The doc chapters are entitled "fnmatch — Unix filename pattern matching" and "glob — Unix style pathname pattern expansion". The first explicitly disclaims the feature you request: "Be aware there is no way to quote meta-characters.", suggests using re for anything beyond fnmatch, and shows to use .translate to make a start in doing so. For your example:

>>> re.match(r".*\[Ver\.2\].*",  "Document[Ver.2].doc")
<_sre.SRE_Match object at 0x000000000331AF38>

Indeed, fnmatch works by using translate() and re.match. What you are asking for in something in between the unix language and re. If one re feature is added, why not another?

So the scope of these modules is clearly circumscribed. I suspect their intent was to make it easy to translate unix shell scripts into Python. 
What you are asking for in something in between. If you want to pursue this, post on python-list or python-ideas to garner more support. But I anticipate rejection as not needed and contrary to intent.

Not obvious from the doc is that an unmatch '[' or ']' is escaped:
>>> name = "Document[Ver.2.doc"
>>> pattern = "*[Ver.2*"
>>> fnmatch.fnmatch(name, pattern)
True
>>> name = "DocumentVer.2].doc"
>>> pattern = "*Ver.2]*"
>>> fnmatch.fnmatch(name, pattern)
True
I presume this matches the *nix behavior, but don't know.
History
Date User Action Args
2012-02-04 04:41:12terry.reedysetrecipients: + terry.reedy, fruch
2012-02-04 04:41:12terry.reedysetmessageid: <1328330472.06.0.296320613225.issue13929@psf.upfronthosting.co.za>
2012-02-04 04:41:11terry.reedylinkissue13929 messages
2012-02-04 04:41:10terry.reedycreate