Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40248

Re: In win32 and linux platform, os modules has diffreent output order, is it a bug?

From Nobody <nobody@nowhere.com>
Subject Re: In win32 and linux platform, os modules has diffreent output order, is it a bug?
Date 2013-03-01 12:56 +0000
Message-Id <pan.2013.03.01.12.56.50.232000@nowhere.com>
Newsgroups comp.lang.python
References <270cf08f-aefd-436c-a3e6-4adf373d5356@googlegroups.com> <CAMZYqRQRRKD2V_X+wRRrJeg9z15tPXTTRr8CY_RB1Ly5dy-DpQ@mail.gmail.com> <mailman.2711.1362129847.2939.python-list@python.org>
Organization Zen Internet

Show all headers | View raw


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.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

In win32 and linux platform, os modules has diffreent output order, is it a bug? Honghe Wu <leopardsaga@gmail.com> - 2013-03-01 00:43 -0800
  Re: In win32 and linux platform, os modules has diffreent output order, is it a bug? Benjamin Kaplan <benjamin.kaplan@case.edu> - 2013-03-01 01:01 -0800
  Re: In win32 and linux platform, os modules has diffreent output order, is it a bug? Chris Rebert <clp2@rebertia.com> - 2013-03-01 00:55 -0800
  Re: In win32 and linux platform, os modules has diffreent output order, is it a bug? Honghe Wu <leopardsaga@gmail.com> - 2013-03-01 17:24 +0800
    Re: In win32 and linux platform, os modules has diffreent output order, is it a bug? Nobody <nobody@nowhere.com> - 2013-03-01 12:56 +0000

csiph-web