Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'win32': 0.03; 'output': 0.04; 'subject:bug': 0.05; '"the': 0.07; 'root,': 0.07; 'python': 0.09; 'internally': 0.09; 'subject:modules': 0.09; 'cc:addr:python-list': 0.10; '2.7.3': 0.16; 'dirs,': 0.16; 'fetches': 0.16; 'filesystem,': 0.16; 'subject: \n ': 0.16; 'wrote:': 0.17; '(or': 0.18; 'email addr:gmail.com>': 0.20; 'equivalent': 0.20; 'bug?': 0.22; 'cheers,': 0.23; 'cc:2**0': 0.23; '>': 0.23; 'dependent': 0.23; 'cc:no real name:2**0': 0.24; 'linux': 0.24; 'allows': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'thanks!': 0.26; '(e.g.': 0.27; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'chris': 0.28; 'cases.': 0.29; 'i/o': 0.29; 'obscure': 0.29; '"the': 0.29; 'maybe': 0.29; 'fri,': 0.30; 'print': 0.32; 'received:74.125.82': 0.33; 'directory,': 0.33; 'docs': 0.33; 'code:': 0.33; 'likely': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'pm,': 0.35; 'subject:?': 0.35; 'but': 0.36; 'received:74.125': 0.36; 'test': 0.36; 'uses': 0.37; 'listing': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'skip:o 20': 0.38; 'performance': 0.39; 'list,': 0.39; 'header:Received:5': 0.40; 'subject:, ': 0.61; 'procedure': 0.61; 'improved': 0.62; 'more': 0.63; 'below:': 0.71; 'lack': 0.71; '2013': 0.84; 'different.': 0.84; 'moral': 0.84; 'abc': 0.91; 'factors': 0.95 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=bJDH+nMnFfIGGCnPwJEhcdUITwWyIh01LOYJ8pPYk+Q=; b=tBCizeMEXvyuu92y2PsM4BmEscvMRV/XJmQ2TsH5ccrV+7yzxdno2gHYVoSyKlEy7t Ru6O3dXLqSQwYND7+473Bp1Dcja5PcELieZQf9vfrtGP2mKL8NymaOftxUZaBEXm+A0L AbS0+E9yngv0+zG9a6VqiqW0/VyBFtBKMlU+bgFlCushLWichhftFmpcF/3Ryty2vTkc 5bgnjTGT7rcupYF4nmrb6hhiTFYPqjASopxar6o5fjf++YWk6E8LRSrI7fqJ3vklKX0C V96Nah9+kU69/spQHgOrZSKOKs2VaSCa3rzy+4EQU8K2t1Rqu/z2H72tazGILbXmkDBL 6XVg== MIME-Version: 1.0 X-Received: by 10.180.75.110 with SMTP id b14mr38334746wiw.21.1362129845308; Fri, 01 Mar 2013 01:24:05 -0800 (PST) In-Reply-To: References: <270cf08f-aefd-436c-a3e6-4adf373d5356@googlegroups.com> Date: Fri, 1 Mar 2013 17:24:05 +0800 Subject: Re: In win32 and linux platform, os modules has diffreent output order, is it a bug? From: Honghe Wu To: Chris Rebert Content-Type: multipart/alternative; boundary=f46d043be22891549004d6d99162 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 86 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362129847 news.xs4all.nl 6981 [2001:888:2000:d::a6]:42685 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40239 --f46d043be22891549004d6d99162 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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. On Mar 1, 2013 4:55 PM, "Chris Rebert" wrote: > On Fri, Mar 1, 2013 at 12:43 AM, Honghe Wu wrote: > > env: python 2.7.3 > > > > 6 test files' name in a directory as below: > > 12ab Abc Eab a1bc acd bc > > > > the following is test code: > > for root, dirs, files in os.walk(os.getcwd()): > > print files > > > > the output in win32 platform is: > > ['12ab', 'a1bc', 'Abc', 'acd', 'bc', 'Eab'] > > > > but in linux is=EF=BC=9A > > ['Eab', 'acd', 'a1bc', '12ab', 'bc', 'Abc' ] > > > > they are so different. a bug? > > Nope. When os.walk() fetches a listing of the contents of a directory, > it internally uses os.listdir() (or a moral equivalent thereof). The > docs for os.listdir() state that "The [returned] list is in arbitrary > order.". The order is dependent on the OS and filesystem, and likely > also more obscure factors (e.g. the order in which the files were > created). The lack of any required ordering allows for improved I/O > performance in many/most cases. > > Cheers, > Chris > --f46d043be22891549004d6d99162 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Thanks! Cause I need sorted returnd list, and the arbitrary list makes t= he other procedure go wrong. Maybe the I/O speed is more important in other= cases.

On Mar 1, 2013 4:55 PM, "Chris Rebert"= <clp2@rebertia.com> wrote:<= br type=3D"attribution">
On Fri, Mar 1, 2013 at 12:43 AM, Honghe Wu <leopardsaga@gmail.com> wrote:
> env: python 2.7.3
>
> 6 test files' name in a directory as below:
> 12ab =C2=A0Abc =C2=A0Eab =C2=A0a1bc =C2=A0acd =C2=A0bc
>
> the following is test code:
> for root, dirs, files in os.walk(os.getcwd()):
> =C2=A0 =C2=A0 print files
>
> the output in win32 platform is:
> ['12ab', 'a1bc', 'Abc', 'acd', 'bc= ', 'Eab']
>
> but in linux is=EF=BC=9A
> ['Eab', 'acd', 'a1bc', '12ab', 'bc= ', 'Abc' ]
>
> they are so different. a bug?

Nope. When os.walk() fetches a listing of the contents of a directory,
it internally uses os.listdir() (or a moral equivalent thereof). The
docs for os.listdir() state that "The [returned] list is in arbitrary<= br> order.". The order is dependent on the OS and filesystem, and likely also more obscure factors (e.g. the order in which the files were
created). The lack of any required ordering allows for improved I/O
performance in many/most cases.

Cheers,
Chris
--f46d043be22891549004d6d99162--