using os
Jerry Sievers
jerry at jerrysievers.com
Mon Nov 29 17:12:44 EST 2004
Juliano Freitas <jubafre at atlas.ucpel.tche.br> writes:
> how can i get just the directories in other directorie without a
> files using the os module in Python??
If there's a command for listing only dirs, I've not stumbled on it.
Here's a one-liner using filter and lambda;
from os import listdir
from os.path import isdir
dir = '/tmp/'
onlyDirs = filter(lambda entry: isdir(dir + entry), listdir(dir))
HTH
--
-------------------------------------------------------------------------------
Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant
305 321-1144 (mobile http://www.JerrySievers.com/
More information about the Python-list
mailing list