os.listdir
Christos TZOTZIOY Georgiou
tzot at sil-tec.gr
Tue Sep 9 03:48:10 EDT 2003
On 8 Sep 2003 15:41:58 -0700, rumours say that pulapaka at ligo.caltech.edu
(Hari) might have written:
>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?
No, the order of filenames in os.listdir depends on underlying
(file|operating) system.
The easiest way to find differences would be to use sets. Example:
check the /tmp directory for changes in 30 seconds time:
>>> import os, time
>>> import sets
>>> os.chdir("/tmp")
>>> files0 = sets.Set(os.listdir("."))
>>> time.sleep(30)
files1 = sets.Set(os.listdir("."))
>>> >>> print files1 - files0
Set(['new-file'])
ie shows only the file I created in another session for the purpose of
this example.
--
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.
More information about the Python-list
mailing list