469,327 Members | 1,265 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

glob and curly brackets

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

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

Apr 7 '06 #1
2 4368
You just need to literlize them with a forward slash.

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

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

See if that works for you.

Apr 7 '06 #2
This would indeed be a nice feature.
The glob module is only 75 lines of pure python. Perhaps you would
to enhance it? Take a look.

Apr 7 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

21 posts views Thread by deko | last post: by
8 posts views Thread by Ken in Melbourne Australia | last post: by
4 posts views Thread by Python Dunce | last post: by
1 post views Thread by inquirydog | last post: by
6 posts views Thread by Hitesh | last post: by
3 posts views Thread by Grande News | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by listenups61195 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.