Re: Newbie Question: Getting a list of files

2007-05-16 Thread Brian
Thank you very much for your examples! Much appreciated. Dusty --- Ant wrote: > On May 16, 3:07 pm, Gerard Flanagan <[EMAIL PROTECTED]> wrote: > ... >> import os >> >> def iter_dirs(root, dirs=False): > ... > > Rather than rolling your own directory walker: > > The same iterator using os.walk

Re: Newbie Question: Getting a list of files

2007-05-16 Thread Ant
On May 16, 3:07 pm, Gerard Flanagan <[EMAIL PROTECTED]> wrote: ... > import os > > def iter_dirs(root, dirs=False): ... Rather than rolling your own directory walker: The same iterator using os.walk: def iter_dirs(root, dirs=False): for root, directories, files in os.walk(root): if d

Re: Newbie Question: Getting a list of files

2007-05-16 Thread Gerard Flanagan
On May 16, 2:12 am, Brian <[EMAIL PROTECTED]> wrote: > How do I, in Python, obtain a recursive list of files in a specified > directory, including the subdirectories, etc? import os def iter_dirs(root, dirs=False): stack = [root] while stack: dir = stack.pop(0) for f in (

Re: Newbie Question: Getting a list of files

2007-05-16 Thread Brian
Hi Steven, Thanks for all of the good advice! Much appreciated. Dusty --- Steven D'Aprano wrote: > On Tue, 15 May 2007 17:12:01 -0700, Brian wrote: > >> How do I, in Python, obtain a recursive list of files in a specified >> directory, including the subdirectories, etc? For example, in the ol

Re: Newbie Question: Getting a list of files

2007-05-15 Thread Steven D'Aprano
On Tue, 15 May 2007 17:12:01 -0700, Brian wrote: > How do I, in Python, obtain a recursive list of files in a specified > directory, including the subdirectories, etc? For example, in the old > MS-DOS days, we could specify at the command prompt "DIR /S" and this > would provide a listing of all

Re: Newbie Question: Getting a list of files

2007-05-15 Thread John Machin
On May 16, 10:12 am, Brian <[EMAIL PROTECTED]> wrote: > Hello, > > I am currently working on putting together a free, open source, > anti-spyware program for the Mac (and eventually for other OS's too.) > However, there's one thing that I am currently trying to figure out: > > How do I, in Python,