globbing problems

Laurent Szyster laurent.szyster at q-survey.be
Sun Jan 20 20:29:19 EST 2002


Works also with Python 2.0:

Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import glob
>>> glob.glob(r'c:\Program Files\*')
['c:\\Program Files\\Common Files', ...]

Jason Orendorff wrote:
> 
> 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