globbing problems

Laurent Szyster laurent.szyster at q-survey.be
Sat Jan 19 16:54:19 EST 2002


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')

it consider the string passed as a list of pattern to "glob",
separated by white spaces.

i suggest you use:

   glob(r'c:\Foo?Bar\*.foo')

or use a wrapper:

   def my_glob(s):
       return glob(s.replace (' ', '?'))


Laurent

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, i.e. all the files in the directory ending
> with .foo; shouldn't the glob do that too? I've looked in the glob
> implementation, but can't find the bug/feature responsible for this.
> 
> Am I being dense here, or is there something wrong with the glob
> implementation?
> 
> --
> Magnus Lie Hetland                                  The Anygui Project
> http://hetland.org                                  http://anygui.org



More information about the Python-list mailing list