Message77216
As I mentioned on python-ideas, I my project needs to extend fnmatch to
support zsh-style globbing, where you can use brackets to designate
subexpressions. Say you had a directory structure like this:
foo/
foo.ext1
foo.ext2
bar/
foo.ext1
foo.ext2
The subexpressions will let you do patterns like this:
>>> glob.glob('foo/foo.{ext1,ext2}')
['foo/foo.ext1', 'foo/foo.ext2']
>>> glob.glob('foo/foo.ext{1,2}')
['foo/foo.ext1', 'foo/foo.ext2']
>>> glob.glob('{foo,bar}')
['bar', 'foo']
>>> glob.glob('{foo,bar}/foo*')
['bar/foo.ext1', 'bar/foo.ext2', 'foo/foo.ext1', 'foo/foo.ext2']
>>> glob.glob('{foo,bar}/foo.{ext*}')
['bar/foo.ext1', 'bar/foo.ext2', 'foo/foo.ext1', 'foo/foo.ext2']
>>> glob.glob('{f?o,b?r}/foo.{ext*}')
['bar/foo.ext1', 'bar/foo.ext2', 'foo/foo.ext1', 'foo/foo.ext2']
Would this be interesting to anyone else? It would unfortunately break
fnmatch since it currently treats {} as ordinary characters. It'd be
easy to work around that by adding a flag or using a different function
name though. Anyway, here's the patch against the head of py3k. |
|
Date |
User |
Action |
Args |
2008-12-07 08:17:57 | erickt | set | recipients:
+ erickt |
2008-12-07 08:17:57 | erickt | set | messageid: <1228637877.49.0.438531462048.issue4573@psf.upfronthosting.co.za> |
2008-12-07 08:17:56 | erickt | link | issue4573 messages |
2008-12-07 08:17:55 | erickt | create | |
|