Directory in Windows
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Sat Apr 30 16:33:55 EDT 2005
In <1114885529.537692.178620 at l41g2000cwc.googlegroups.com>, custard_pie
wrote:
> Here's my code
> ========================================================
> filelist={}
> def listFiles(self, dirName, filesInDir):
> for fname in filesInDir:
> if os.path.isfile(fname):
`fname` contains just the file name without the path to the file. So this
gives `False` for every file name except if there's a file with the same
name in the current working directory.
> key = os.path.join(dirName, fname)
> stats = os.stat(fname)
Same problem with `stat()`. Move the assignment to `key` up and use that
to check with `isfile()`/`isdir()` and `stat()`.
> filelist[key] = (stats[stat.ST_MTIME], stats[stat.ST_SIZE])
> os.path.walk(string.strip(self.path.get()), listFiles, None)
> print filelist
> =======================================================
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list