os.listdir
Jeremy Jones
zanesdad at bellsouth.net
Mon Sep 8 19:59:24 EDT 2003
* Hari (pulapaka at ligo.caltech.edu) wrote:
<snip>
>
> What I wanted to know was, is it guaranteed that between 2 calls
> os.listdir any files added to the directory are appended and the
> earlier order is maintained?
Even if the module does guarantee this to you, you probably don't want to
just rely on the length of the list (nor the order of it). You probably
want to build yourself a dictionary and keep track of it that way. One
reason is that you may not be able to guarantee that a file didn't get
deleted out of the directory. Even if you think you are in total control
of that filesystem, I still wouldn't trust that no files would be deleted.
I dunno, maybe I'm just paranoid. Further, as the value of the dictionary
(didn't mention this above, but I'd let the filename serve as the key), I'd
do os.stat and use the last modified date. Again, maybe I'm just paranoid.
Jeremy Jones
>
> thanks,
>
> Hari
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list