How to separate directory list and file list?

Peter Hansen peter at engcorp.com
Sun Oct 23 12:23:14 EDT 2005


Gonnasi wrote:
> With
>>glob.glob("*")
> or
>>os.listdir(cwd)
> 
> I can get a combined file list with directory list, but I just wanna a
> bare file list, no directory list. How to get it?

Using Jason Orendorff's path module, it's just this:

 >>> from path import path
 >>> path('.').files()  # returns list of files in current dir


-Peter



More information about the Python-list mailing list