Re: Gettings subdirectories

2006-05-04 Thread Philippe Martin
Hi, The second edition of Programming Python - O'REILLY - Mark Lutz shows how to do that using os.path.walk Philippe Florian Lindner wrote: Hello, how can I get all subdirectories of a given directories? os.listdir() gives me all entries and I've found no way to tell if an object is a

Re: Gettings subdirectories

2006-05-04 Thread Lou Losee
import os.pathos.path.isdir(file)LouOn 5/4/06, Philippe Martin [EMAIL PROTECTED] wrote: Hi,The second edition of Programming Python - O'REILLY - Mark Lutz shows how to do that using os.path.walkPhilippeFlorian Lindner wrote: Hello, how can I get all subdirectories of a given directories?

Re: Gettings subdirectories

2006-05-04 Thread alex23
Florian Lindner wrote: how can I get all subdirectories of a given directories? If you're not adverse to a solution outside of the standard lib, I highly recommend the 'path' module: from path import path c = path(C:\\) c.dirs() [path(u'C:\\cmdcons'), path(u'C:\\Config.Msi'),

Gettings subdirectories

2006-05-03 Thread Florian Lindner
Hello, how can I get all subdirectories of a given directories? os.listdir() gives me all entries and I've found no way to tell if an object is a file or a directory. Thanks, Florian -- http://mail.python.org/mailman/listinfo/python-list

Re: Gettings subdirectories

2006-05-03 Thread Sybren Stuvel
Florian Lindner enlightened us with: how can I get all subdirectories of a given directories? os.listdir() gives me all entries and I've found no way to tell if an object is a file or a directory. Why, doesn't your os.path.isdir() function work? Sybren -- The problem with the world is

Re: Gettings subdirectories

2006-05-03 Thread johnzenger
It's a bit overkill, but consider using os.walk. root, dirnames, filenames = os.walk(rC:\).next() # (in real code, you'd want to catch exceptions here) print dirnames Florian Lindner wrote: Hello, how can I get all subdirectories of a given directories? os.listdir() gives me all entries and

Re: Gettings subdirectories

2006-05-03 Thread BartlebyScrivener
root, dirnames, filenames = os.walk(rC:\).next() Wow. How does that work? Just point me to where I can read about it. I don't see it under os.walk. That's cool. Thanks, Rick -- http://mail.python.org/mailman/listinfo/python-list

Re: Gettings subdirectories

2006-05-03 Thread Ben Finney
BartlebyScrivener [EMAIL PROTECTED] writes: root, dirnames, filenames = os.walk(rC:\).next() Wow. How does that work? Just point me to where I can read about it. I don't see it under os.walk. We must be reading different Python websites. walk(top[, topdown=True [, onerror=None]])

Re: Gettings subdirectories

2006-05-03 Thread Edward Elliott
Ben Finney wrote: We must be reading different Python websites. walk(top[, topdown=True [, onerror=None]]) walk() generates the file names in a directory tree, by walking the tree either top down or bottom up. For each directory in the tree rooted at directory top

Re: Gettings subdirectories

2006-05-03 Thread BartlebyScrivener
Sorry that I was unclear. I sorta know how os.walk works. It's the .next() trick that I had never seen before. For instance, if you run that statement without the .next() on it, it says Too many items to unpack but with the .next() it stops it somehow, right where I want it to stop. It's an

Re: Gettings subdirectories

2006-05-03 Thread Adonis
Florian Lindner wrote: Hello, how can I get all subdirectories of a given directories? os.listdir() gives me all entries and I've found no way to tell if an object is a file or a directory. Thanks, Florian Here is a quick hack: import os import os.path givenDir = / listing =

Re: Gettings subdirectories

2006-05-03 Thread BartlebyScrivener
Thank you all for the great info and education. rick -- http://mail.python.org/mailman/listinfo/python-list