Message30301
| Author |
peter.otten |
| Recipients |
| Date |
2006年10月27日.12:32:30 |
| SpamBayes Score |
| Marked as misclassified |
| Message-id |
| In-reply-to |
| Content |
Logged In: YES
user_id=703365
Not a bug. "[abc]" matches exactly one character which may be "a", "b" or "c".
Therefore "[ ]" matches one space character. If you want a literal "[", put it in brackets,
e. g. glob.glob("C:\\[[] ]\\*").
---
By the way, do you think this problem is common enough to warrant the addition of a
fnmatch.escape() function? I have something like this in mind:
>>> import re
>>> r = re.compile("(%s)" % "|".join(re.escape(c) for c in "*?["))
>>> def escape(s):
... return r.sub(r"[1円]", s)
...
>>> escape("c:\\[a-z]\\*")
'c:\\[[]a-z]\\[*]'
|
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2007年08月23日 14:44:03 | admin | link | issue1580472 messages |
| 2007年08月23日 14:44:03 | admin | create |
|