globbing problems

Jason Orendorff jason at jorendorff.com
Sat Jan 19 17:06:10 EST 2002


Laurent Szyster wrote:
> Magnus Lie Hetland wrote:
> > 
> > I'm trying to use globs of the type
> >   glob(r'c:\Foo Bar\*.foo')
> > in Windows, but only get returned an empty list. When I use
> >   fnmatch.filter(os.listdir(r'c:\Foo Bar'), '*.foo')
> > I get all the files I want [...]
>
> Magnus,
> AFAIK glob is implemented as its UN*X sibbling. So:
>    glob(r'c:\Foo Bar\*.foo')
> is equivalent to:
>    glob(r'c:\Foo)+ glob(r'Bar\*.foo')

No; it works for me.

Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32
>>> import glob
>>> glob.glob(r"C:\Program Files\Python22\lib\h*.py")
['C:\\Program Files\\Python22\\lib\\hmac.py',
'C:\\Program Files\\Python22\\lib\\htmlentitydefs.py',
'C:\\Program Files\\Python22\\lib\\htmllib.py',
'C:\\Program Files\\Python22\\lib\\HTMLParser.py',
'C:\\Program Files\\Python22\\lib\\httplib.py']

Perhaps Magnus is using an old version of Python...?

## Jason Orendorff    http://www.jorendorff.com/




More information about the Python-list mailing list