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


Groups > comp.lang.python > #32805

Re: How to only get a list of the names of the non-directory files in current directory ('.')?

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.016
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'exception': 0.03; 'subject:How': 0.09; 'excluding': 0.09; 'subject:files': 0.09; '(note': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject: \n ': 0.16; 'subject:non': 0.16; 'wrote:': 0.17; 'directory.': 0.17; 'code,': 0.18; 'received:209.85.214.174': 0.21; 'second': 0.24; 'testing': 0.24; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'there.': 0.28; 'subject:list': 0.28; 'post': 0.28; 'code': 0.31; 'getting': 0.33; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'done': 0.34; 'list': 0.35; 'filter': 0.35; 'nov': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'received:209': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'step': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'skip:n 10': 0.63; 'difficulty': 0.65; 'subject:get': 0.81; 'fun!': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=SxytQXLOAYiDjgqGbdUri6Q9EA5S5eK567TkhOTxGdE=; b=t71xe+aBsqy6sLNJcUcFBfFDWCMXZIrJ0w8I6RoBeiS7HtPqShpX1PziVtt1fjNCML BI8Phh6zpYe6ynvXhE7z7bUK6m9sOsh7ndwJOmc+nahpM8Fmv35T9VO+U72ibvGlXJYv rMSAGEuNrbBsdV6AqZu8qOK7oytUrbnJUFjJJ99cVEhT1j5TwKqXk4tfLRfJrZs5iNDI Hh47dPb5843OhWUSAdEw0AA3HLcERy58GuBpjsmtqQDthWAPN94O450XDYXG+ulft/nS iwZ1KVLV11MErAZFiHlGK1a1/sEPaocJaiAHw5q6Bndzz6b8zajnOGpV5RpmSIZtDL/x Mf/A==
MIME-Version 1.0
In-Reply-To <d9b687d7-e982-4a7c-b1f9-ef38ec6ce183@googlegroups.com>
References <d9b687d7-e982-4a7c-b1f9-ef38ec6ce183@googlegroups.com>
Date Tue, 6 Nov 2012 16:24:38 +1100
Subject Re: How to only get a list of the names of the non-directory files in current directory ('.')?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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.3310.1352179480.27098.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1352179480 news.xs4all.nl 6978 [2001:888:2000:d::a6]:53671
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32805

Show key headers only | View raw


On Tue, Nov 6, 2012 at 4:19 PM, iMath <redstone-cold@163.com> wrote:
> How to only get a list of the names of the non-directory files in current directory ('.')?
> (Note excluding its subdirectories ).
>
> I need the code : )

Start by getting a list of names of everything in the current directory.

Then filter that list by testing each one to see if it's a directory.

Tip: The second step can be done with os.path.isdir

Put some code together and try it. If you have trouble, post your
code, any exception traceback you get, and what you're having
difficulty with, and we'll go on from there.

Have fun!

ChrisA

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


Thread

How to only get a list of the names of the non-directory files in current directory ('.')? iMath <redstone-cold@163.com> - 2012-11-05 21:19 -0800
  Re: How to only get a list of the names of the non-directory files in current directory ('.')? Chris Angelico <rosuav@gmail.com> - 2012-11-06 16:24 +1100
    Re: How to only get a list of the names of the non-directory files in current directory ('.')? iMath <redstone-cold@163.com> - 2012-11-06 15:12 -0800
      RE: How to only get a list of the names of the non-directory files in current directory ('.')? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-06 23:41 +0000
      Re: How to only get a list of the names of the non-directory files in current directory ('.')? emile <emile@fenx.com> - 2012-11-13 10:16 -0800
      Re: How to only get a list of the names of the non-directory files in current directory ('.')? Chris Angelico <rosuav@gmail.com> - 2012-11-14 07:53 +1100
        Re: How to only get a list of the names of the non-directory files in current directory ('.')? John Gordon <gordon@panix.com> - 2012-11-13 21:05 +0000
          Re: How to only get a list of the names of the non-directory files in current directory ('.')? Chris Angelico <rosuav@gmail.com> - 2012-11-14 08:19 +1100
          Re: How to only get a list of the names of the non-directory files in current directory ('.')? emile <emile@fenx.com> - 2012-11-13 13:24 -0800
    Re: How to only get a list of the names of the non-directory files in current directory ('.')? iMath <redstone-cold@163.com> - 2012-11-06 15:12 -0800
      Re: How to only get a list of the names of the non-directory files in current directory ('.')? John Gordon <gordon@panix.com> - 2012-11-06 23:23 +0000

csiph-web