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

Tim Peters tim.one at comcast.net
Mon Dec 1 09:41:00 EST 2003


>> ?  Nope.  It's dir that special-cases the snot out of a period, not
>> Python's glob.

[Duncan Booth]
> On that basis Python also 'special-cases the snot out of a period':
> try win32api.FindFiles('*.') to get the same behaviour as dir.

It's the intent of win32api.FindFiles to wrap the Win32 API FindFiles()
function, so of course it exposes Win32-specific behavior.  It's the purpose
of glob.glob() to give platform-independent results to the extent possible.

> More accurate would be to say that the operating system has
> consistent but weird behaviour, since it is below the application
> level that trailing dots are stripped from filenames and ignored from
> file patterns. The only way to avoid it on Windows is to retrieve all
> the filenames and then perform your own pattern matching on them.

Which glob.glob() does for you.

> glob.glob is bypassing the operating system's filename matching to
> provide behaviour which is consistent across different operating
> systems,

Yes.

> but inevitably this means that it doesn't match some platform's
> standard behaviour.

Of course -- "may not match native platform behavior" is necessarily implied
by "platform-independent".






More information about the Python-list mailing list