using os

J

Juliano Freitas

how can i get just the directories in other directorie without a files
using the os module in Python??


Juliano
 
J

Jerry Sievers

Juliano Freitas said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,212
Messages
2,571,101
Members
47,695
Latest member
KayleneBee

Latest Threads

Top