Bug in glob.glob for files w/o extentions in Windows
tim.one at comcast.net
Sun Nov 30 05:16:19 CET 2003
> On Windows XP glob.glob doesn't work properly for files without
I'd say it's Microsoft's dir that doesn't work properly in this case.
> E.g. C:\Temp contains 4 files: 2 with extensions, 2
> C:\Temp>dir /b *
> C:\Temp>dir /b *.
Why on Earth should a pattern specifying a period match filenames that don't
contain a period? Would you expect
? Nope. It's dir that special-cases the snot out of a period, not Python's
glob. For cross-platform sanity, glob has to work the same way across
platforms, and the Unixish shells have the obvious, explainable,
unsurprising semantics here:
$ ls *
aaaaa.aaa bbbbb.bbb ccccc ddddd
$ ls *.
ls: *.: No such file or directory
$ ls *.*
> Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)]
> on win32 Type "help", "copyright", "credits" or "license" for more
> >>> import glob
> >>> glob.glob( '*' )
> ['aaaaa.aaa', 'bbbbb.bbb', 'ccccc', 'ddddd']
> >>> glob.glob( '*.' )
> It looks like a bug.
Good luck getting Microsoft to fix it <wink>.
More information about the Python-list