On 11/20/2010 11:03 AM Kirk Bailey said...
OK, I need to create or find a function that will return a list of
DIRECTORIES (only) which are under 'the current directory'. Anyone got
some clue on this? Please advise.
Use os.walk
Emile
Help on function walk in module os:
walk(top, topdown=True, onerror=None, followlinks=False)
Directory tree generator.
For each directory in the directory tree rooted at top (including top
itself, but excluding '.' and '..'), yields a 3-tuple
dirpath, dirnames, filenames
dirpath is a string, the path to the directory. dirnames is a list of
the names of the subdirectories in dirpath (excluding '.' and '..').
filenames is a list of the names of the non-directory files in dirpath.
Note that the names in the lists are just names, with no path
components.
To get a full path (which begins with top) to a file or directory in
dirpath, do os.path.join(dirpath, name).
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor