pyfilesystem2 icon indicating copy to clipboard operation
pyfilesystem2 copied to clipboard

glob on windows local file system produces different results to glob.glob

Open simonm3 opened this issue 5 years ago • 3 comments

Is glob intended to produce same results as glob.glob? They seem to be different at least on windows local file system.

import fs
from glob import glob
local = fs.open_fs("")
glob("test"), [x.path for x in local.glob("test")]

(['test'], []) #####################################

glob("test/*"), [x.path for x in local.glob("test/*")] (['test\pilot'], ['/test/'])

##################################### [x.path for x in local.glob("test/**")] produces same results as glob("test/**", recursive=True) but takes over 6 seconds whereas native glob takes 3ms!

simonm3 avatar Apr 30 '20 12:04 simonm3

It seems pyfilesystem2 matches files only but glob.glob matches folders as well.

simonm3 avatar Apr 30 '20 12:04 simonm3

I dunno what the intended PyFilesystem behaviour is, but the documentation is unfortunately a bit ambiguous. :confused: It says both "If the glob pattern ends in a /, it will only match directory paths, otherwise it will match files and directories." and also "* Matches all files in the current directory."

lurch avatar Apr 30 '20 19:04 lurch

It's not just on Windows. On Linux too * should match files and directories, but PyFilesystem's glob yields only files... is there any kind of system where people would expect * to match files only?

smheidrich avatar Oct 22 '20 12:10 smheidrich