[Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info (original) (raw)

Victor Stinner victor.stinner at gmail.com
Mon May 13 02:11:28 CEST 2013


2013/5/13 Ben Hoyt <benhoyt at gmail.com>:

class DirEntry: def init(self, name, dirent, lstat, path='.'): # User shouldn't need to call this, but called internally by scandir() self.name = name self.dirent = dirent self.lstat = lstat # non-public attributes self.path = path

def lstat(self): if self.lstat is None: self.lstat = os.lstat(os.path.join(self.path, self.name)) return self.lstat ...

You need to provide a way to invalidate the stat cache, DirEntry.clearcache() for example.

Victor



More information about the Python-Dev mailing list