En Thu, 10 Apr 2008 06:55:13 -0300, Soren <[EMAIL PROTECTED]>  
escribió:

> I'd like to read the filenames in a directory, but not the
> subdirectories, os.listdir() gives me everything... how do I separate
> the directory names from the filenames? Is there another way of doing
> this?

Check each returned name using os.path.isfile
(untested):

def files_only(path):
   return [filename for filename in os.listdir(path)
           if os.path.isfile(os.path.join(path, filename))]

-- 
Gabriel Genellina

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

Reply via email to