Get all subdirs
Peter Kleiweg
in.aqua.scribis at nl.invalid
Sun Aug 29 09:22:57 EDT 2004
Florian Lindner schreef:
> Hello,
> how can I get all subdirectories of a given directory. os.listdir(dir)
> doesn't differentiate between directories and files, os.walk seems to me a
> bit overkill since it also descends in the subdirs.
#!/usr/bin/env python
import os
dir = '.' # '.' is current directory
for i in os.listdir(dir):
if os.path.isdir(os.path.join(dir, i)):
print i
Bby the way, on Linux, I noticed that the directories '.' and
'..' are not returned by os.listdir
--
Peter Kleiweg L:NL,af,da,de,en,ia,nds,no,sv,(fr,it) S:NL,de,en,(da,ia)
info: http://www.let.rug.nl/~kleiweg/ls.html
More information about the Python-list
mailing list