Re: Partial directory search question

2009-09-30 Thread lallous
chad cdal...@gmail.com wrote in message news:4e260ef3-8b0e-4613-a4f8-1c267e875...@u16g2000pru.googlegroups.com... On Sep 29, 7:20 pm, Tim Chase python.l...@tim.thechases.com wrote: What's the sanest way to print out all the files in the directory that start with the underscore? Ie, I just

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 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 cdal...@gmail.com wrote: On Sep 29, 7:20 pm, Tim

Re: Partial directory search question

2009-09-30 Thread alex23
Tim Chase python.l...@tim.thechases.com 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

Partial directory search question

2009-09-29 Thread chad
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. -- http://mail.python.org/mailman/listinfo/python-list

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

Re: Partial directory search question

2009-09-29 Thread chad
On Sep 29, 7:20 pm, Tim Chase python.l...@tim.thechases.com 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

Re: Partial directory search question

2009-09-29 Thread chad
On Sep 29, 7:52 pm, chad cdal...@gmail.com wrote: On Sep 29, 7:20 pm, Tim Chase python.l...@tim.thechases.com 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

Re: Partial directory search question

2009-09-29 Thread Martien Verbruggen
On Tue, 29 Sep 2009 19:09:16 -0700 (PDT), chad cdal...@gmail.com 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,