Bug in glob.glob for files w/o extentions in Windows

Jules Dubois bogus at invalid.tld
Sun Nov 30 00:54:04 EST 2003


On Sun, 30 Nov 2003 03:47:38 GMT, in article
<news:uLdyb.46389$I53.2118790 at twister.southeast.rr.com>, Georgy Pruss
wrote:

> On Windows XP glob.glob doesn't work properly for files without extensions.
> E.g. C:\Temp contains 4 files: 2 with extensions, 2 without.
> [...]
> C:\Temp>dir /b *.
> ccccc
> ddddd

This is standard Windows behavior.  It's compatible with CP/M and therefore
MS-DOS, and Microsoft has preserved this behavior in all versions of
Windows.  

Did you ever poke around in the directory system in a FAT partition
(without VFAT)?  You'll find that every file name is exactly 11 characters
long and "." is not found in any part of any file name in any directory
entry.

It's bizarre but that's the way it works.  If you try

  dir /b *

does cmd.exe list only files without extensions?

>>>> glob.glob( '*.' )
> []
> 

glob provides "Unix style pathname pattern expansion" as documented in the
_Python Library Reference_: If there's a period (".") in the pattern, it
must match a period in the filename.

> It looks like a bug.

No, it's proper behavior.  It's Windows that's (still) screwy.




More information about the Python-list mailing list