Re: Partial directory search question

2009-09-30 Thread alex23
Tim Chase wrote: > If you're doing more processing than just printing it, your > for-loop is a better (clearer) way to go.  If you have lots of > processing code, it might help to do the inverse: > >    for filename in os.listdir(location): >      if not filename.startswith('_'): continue >      l

Re: Partial directory search question

2009-09-30 Thread Rami Chowdhury
Rami Chowdhury "Never attributed to malice that which can be attributed to stupidity." -- Hanlon's Razor 408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD) On Tuesday 29 September 2009 19:54:17 chad wrote: > On Sep 29, 7:52 pm, chad wrote: > > On Sep 29, 7:20 pm, Tim Chase wrote:

Re: Partial directory search question

2009-09-30 Thread Tim Chase
import os for filename in os.listdir("/usr/bbs/confs/september"): #stat = os.stat(filename) if filename.startswith("_"): print filename yes, as lallous mentioned, this can be done as a list-comprehension/generator. If printing is all you want to do, it's a nice and concise

Re: Partial directory search question

2009-09-30 Thread lallous
"chad" wrote in message news:4e260ef3-8b0e-4613-a4f8-1c267e875...@u16g2000pru.googlegroups.com... On Sep 29, 7:20 pm, Tim Chase wrote: > What's the sanest way to print out all the files in the directory that > start with the underscore? Ie, I just want to list _1, _2, _3, _4. I'd use a string

Re: Partial directory search question

2009-09-29 Thread Martien Verbruggen
On Tue, 29 Sep 2009 19:09:16 -0700 (PDT), chad wrote: > I have a directory that contains the following > > login > rc > sum > _1 > _2 > _3 > _4 > > What's the sanest way to print out all the files in the directory that > start with the underscore? Ie, I just want to list _1, _2, _3, _4. I

Re: Partial directory search question

2009-09-29 Thread chad
On Sep 29, 7:52 pm, chad wrote: > On Sep 29, 7:20 pm, Tim Chase wrote: > > > > What's the sanest way to print out all the files in the directory that > > > start with the underscore? Ie, I just want to list _1, _2, _3, _4. > > > I'd use a string's join() method to combine the results of a > > lis

Re: Partial directory search question

2009-09-29 Thread chad
On Sep 29, 7:20 pm, Tim Chase wrote: > > What's the sanest way to print out all the files in the directory that > > start with the underscore? Ie, I just want to list _1, _2, _3, _4. > > I'd use a string's join() method to combine the results of a > list-comprehension or generator that filtered th

Re: Partial directory search question

2009-09-29 Thread Tim Chase
What's the sanest way to print out all the files in the directory that start with the underscore? Ie, I just want to list _1, _2, _3, _4. I'd use a string's join() method to combine the results of a list-comprehension or generator that filtered the output of os.listdir() based on the startswit