easy way to return a list of absolute file or directory path within a directory
iMath
redstone-cold at 163.com
Thu Sep 8 04:17:44 EDT 2016
On Wednesday, September 7, 2016 at 4:00:31 PM UTC+8, Steven D'Aprano wrote:
> 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.
yes, a list comprehension does make the code more readable
More information about the Python-list
mailing list