Get all subdirs

Leif K-Brooks eurleif at ecritters.biz
Sun Aug 29 15:22:00 CEST 2004


Florian Lindner wrote:
> how can I get all subdirectories of a given directory

 >>> import os
 >>> def subdirs(dir):
...     return [filename for filename in os.listdir(dir)
...             if os.path.isdir(os.path.join(dir, filename))]
...
 >>> subdirs('.')
['foo', 'bar', 'baz']



More information about the Python-list mailing list