Bug in glob.glob for files w/o extentions in Windows
Tim Peters
tim.one at comcast.net
Sat Nov 29 23:16:19 EST 2003
[Georgy Pruss]
> On Windows XP glob.glob doesn't work properly for files without
> extensions.
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
> without.
>
> C:\Temp>dir /b *
> aaaaa.aaa
> bbbbb.bbb
> ccccc
> ddddd
>
> C:\Temp>dir /b *.
> ccccc
> ddddd
Why on Earth should a pattern specifying a period match filenames that don't
contain a period? Would you expect
*x
to match
abc
? 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 *.*
aaaaa.aaa bbbbb.bbb
> C:\Temp>python
> 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
> information.
> >>> 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
mailing list