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 erickt
Recipients erickt
Date 2008-12-07.08:17:52
SpamBayes Score 1.5454832e-05
Marked as misclassified No
Message-id <1228637877.49.0.438531462048.issue4573@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2008-12-07 08:17:57ericktsetrecipients: + erickt
2008-12-07 08:17:57ericktsetmessageid: <1228637877.49.0.438531462048.issue4573@psf.upfronthosting.co.za>
2008-12-07 08:17:56ericktlinkissue4573 messages
2008-12-07 08:17:55ericktcreate