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


Groups > comp.lang.python > #40238

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

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'win32': 0.03; 'output': 0.04; 'subject:bug': 0.05; '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; 'equivalent': 0.20; 'bug?': 0.22; 'cheers,': 0.23; 'cc:2**0': 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; '(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; 'fri,': 0.30; 'print': 0.32; 'directory,': 0.33; 'docs': 0.33; 'code:': 0.33; 'likely': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'subject:?': 0.35; 'but': 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; 'subject:, ': 0.61; 'improved': 0.62; 'more': 0.63; 'below:': 0.71; 'lack': 0.71; '2013': 0.84; 'different.': 0.84; 'moral': 0.84; 'sender:addr:chris': 0.84; 'abc': 0.91; 'factors': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=Te+318VrKTaxvkEjR3LwXId4Z50RzIMypISr4tU92PI=; b=AdJXyDqH13KPCAphnuUztNvquMxAvhzl7iR0rfIx226GAhcT1DRVLVteT1CQTgbOxg llCM4+GYaW2F/3ngXJZJHalHcXnKhgqDmtAUqP9eNPfZRVZOCark8PrPR0TZzY+klrds Mvu5TQ34CQGf1OSg287g3dTogRjnmUDQJfGz0=
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding:x-gm-message-state; bh=Te+318VrKTaxvkEjR3LwXId4Z50RzIMypISr4tU92PI=; b=dbuHmQuaP6I0NzvPF5yrrrZOHkpQDeTs/mEYaPBHyvK3ikiouyL1wzr+f2V1B3Eslh 1JXi5ZqUqb3l4sM3eJI8qO5Mb4JDBQzWl8gqEIFF6qmxbI7jkPQ3NfuxgttFh5MxWhDU pzowIynJojRBsuFxNuuwz93pk+L792/qhDjKaLQtfi++qXKmWU4vcoWfp04TtK2K4ZOL x/p6VnlmTrX4cgh20wVyb46kESH56QsDwzRqcDSr2FEDIgq94RZgTiPRjNnFObDiJGC9 3GE0iqAX+uedBdWGHYQWy65i5TJegHAMgGTtTp6bVEXueQAKAMfc+1tWMsScQ+wJ447z JKtg==
MIME-Version 1.0
X-Received by 10.42.58.202 with SMTP id j10mr5211579ich.39.1362128130207; Fri, 01 Mar 2013 00:55:30 -0800 (PST)
Sender chris@rebertia.com
In-Reply-To <270cf08f-aefd-436c-a3e6-4adf373d5356@googlegroups.com>
References <270cf08f-aefd-436c-a3e6-4adf373d5356@googlegroups.com>
Date Fri, 1 Mar 2013 00:55:29 -0800
X-Google-Sender-Auth QQ1UZeZx8EVc4nOaVDLdNUW5feI
Subject Re: In win32 and linux platform, os modules has diffreent output order, is it a bug?
From Chris Rebert <clp2@rebertia.com>
To Honghe Wu <leopardsaga@gmail.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Gm-Message-State ALoCoQnhbKk4JY4qLnWuci6xRj69O6eUHkWdq5igjl6gB47pCFCTzlrucJHlD8xoTFQ/IT/3y0fl
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2710.1362129542.2939.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362129542 news.xs4all.nl 6878 [2001:888:2000:d::a6]:39636
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40238

Show key headers only | View raw


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  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:
> ['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

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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