Re: Directory in Windows
- From: Marc 'BlackJack' Rintsch <bj_666@xxxxxxx>
- Date: Sat, 30 Apr 2005 22:33:55 +0200
In <1114885529.537692.178620@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>, 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
.
- References:
- Directory in Windows
- From: custard_pie
- Re: Directory in Windows
- From: Kent Johnson
- Re: Directory in Windows
- From: custard_pie
- Directory in Windows
- Prev by Date: Re: [newbie] Embedding Flash OCX object
- Next by Date: Re: [newbie] Embedding Flash OCX object
- Previous by thread: Re: Directory in Windows
- Next by thread: [Py Windows] User Directory Path
- Index(es):
Relevant Pages
|