In win32 and linux platform, os modules has diffreent output order, is it a bug?
Nobody
nobody at nowhere.com
Fri Mar 1 07:56:50 EST 2013
On Fri, 01 Mar 2013 17:24:05 +0800, Honghe Wu wrote:
> Thanks! Cause I need sorted returnd list, and the arbitrary list makes the
> other procedure go wrong. Maybe the I/O speed is more important in other
> cases.
You can sort the lists of files and subdirectories with e.g.:
for root, dirs, files in os.walk(os.getcwd()):
dirs[:] = sorted(dirs)
files = sorted(files)
...
Note that modifying the directory list in-place will affect which
subdirectories are traversed and in what order.
More information about the Python-list
mailing list