Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python
os.path.walk -- Can You Limit Directories Returned?
 

Index | Next | Previous | View Flat


jeffnyman at gmail

Jun 4, 2008, 11:54 PM


Views: 234
Permalink
os.path.walk -- Can You Limit Directories Returned?

Greetings all.

I did some searching on this but I can't seem to find a specific
solution. I have code like this:

=========================================
def walker1(arg, dirname, names):
DC_List.append((dirname,''))

os.path.walk('\\\\vcdcflx006\\Flex\\Sites', walker1, 0)
=========================================

The Sites\ directory is set up like this:

Sites\
Baltimore
Birmingham
....

And so forth. Each of the city directories has directories under it as
well. The problem is that my code grabs every single directory that is
under the various city directories when what I really want it to do is
just grab the directories that are under Sites\ and that's it. I don't
want it to recurse down into the sub-directories of the cities.

Is there a way to do this? Or is os.path.walk not by best choice here?

Any help and/or advice would be appreciated.

- Jeff
--
http://mail.python.org/mailman/listinfo/python-list

Subject User Time
os.path.walk -- Can You Limit Directories Returned? jeffnyman at gmail Jun 4, 2008, 11:54 PM
    Re: os.path.walk -- Can You Limit Directories Returned? deets at nospam Jun 5, 2008, 12:00 AM
    Re: os.path.walk -- Can You Limit Directories Returned? gherron at islandtraining Jun 5, 2008, 12:41 AM
    Re: os.path.walk -- Can You Limit Directories Returned? wuwei23 at gmail Jun 5, 2008, 12:56 AM
    Re: os.path.walk -- Can You Limit Directories Returned? jeffnyman at gmail Jun 5, 2008, 5:14 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.