glob & fnmatch unable to match dirs/files containing [ ] ?
peter at engcorp.com
Sun Mar 23 00:33:45 CET 2003
Steven Taschuk wrote:
> Quoth Robert:
> > quoting attempts don't work:
> > >>> glob.glob( r'testsync\[2\]/*' ) # or 'testsync\\[2\\]/*'
> > 
> You can quote the '[' by putting it in a character class of its
> >>> glob.glob('testsync[2]')
I'm not certain, but I believe you would need
to change the order to 'testsync' ... this
looks like an empty class then one with a single 2
in it, but it's not. Yours would look like a single
[ in a class, then a 2 and then... syntax error or
something, since you've got a closing ] without a
matching opening one.
More information about the Python-list