glob and curly brackets

Zain Homer zhomer at ilm.com
Thu Apr 6 23:49:12 EDT 2006


Someone please let me know if I'm sending this to the
wrong email alias...

I'm wondering why we can't use the glob module
to glob with curly brackets like we can from
the command line (at least in tcsh).  Is there a shell standard
for which the python glob module has been designed which
prevents the implimentation of the {}'s?

For example:

I can do this from tcsh:
ls /home/zhomer/test/{dir1*,dir2*}/{subdir1,subdir2}

....and get back a result if something exists there.

However, the python glob module doesn't recognize curly brackets.

globber = '/home/zhomer/test/{dir1*,dir2*}/{subdir1,subdir2}'
globlist = glob.glob(globber)

doesn't work...

I read the glob documentation and I see {} aren't included,
but I'm thinking the curly brackets are pretty standard shell
syntax so I'm wondering why they can't be included with
glob?

python glob is super useful especially since with python we  don't
have the word count limitation that some shells have when
globbing.

Thanks,
-Zain





More information about the Python-list mailing list