homepage

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 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:03adminlinkissue1580472 messages
2007年08月23日 14:44:03admincreate

AltStyle によって変換されたページ (->オリジナル) /