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.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to