Jerry Sievers wrote:
Juliano Freitas <[EMAIL PROTECTED]> 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/'

 entry: isdir(dir + entry), listdir(dir))

HTH


  
Or using list comprehensions:

>>> [f for f in os.listdir('/tmp') if os.path.isdir(os.path.join('/tmp', f))]
['gconfd-root', '.X11-unix', '.ICE-unix', '.mozilla', '.font-unix']

Just as a side note, and just preference, but I typically (almost always) prefer using os.path.join() rather than using the "+" operator to put a path together.


Jeremy Jones
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to