Gettings subdirectories

alex23 wuwei23 at gmail.com
Thu May 4 21:56:57 EDT 2006


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'), path(u'C:\\Logon'),
path(u'C:\\Program Files'), path(u'C:\\Python24'),
path(u'C:\\RECYCLER'), path(u'C:\\System Volume Information'),
path(u'C:\\WINDOWS'), path(u'C:\\WINSRC')]

http://www.jorendorff.com/articles/python/path/

Hope this helps.

- alex23




More information about the Python-list mailing list