easy way to return a list of absolute file or directory path within a directory

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Sep 7 03:59:06 EDT 2016


On Wednesday 07 September 2016 17:08, iMath wrote:

> Any easier solutions on returning a list of absolute file or directory path
> within a directory? Mine is
> 
> list(map(lambda entry: os.path.join(directory,entry),os.listdir(directory)))


Use a list comprehension:


[os.path.join(directory,entry) for entry in os.listdir(directory)]



-- 
Steven

git gets easier once you get the basic idea that branches are homeomorphic 
endofunctors mapping submanifolds of a Hilbert space.




More information about the Python-list mailing list