Terry J. Reedy <tjre...@udel.edu> added the comment:

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.

----------
nosy: +terry.reedy
resolution:  -> rejected
status: open -> closed
versions:  -Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13929>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to