PEP ? os.listdir enhancement
Daniel Dittmar
daniel.dittmar at sap.corp
Thu Jun 23 07:19:45 EDT 2005
Riccardo Galli wrote:
> On Thu, 23 Jun 2005 11:34:02 +0200, Andreas Kostyrka wrote:
>
>
>>What's wrong with
>>
>>(os.path.join(d, x) for x in os.listdir(d))
>>
>>It's short, and easier to understand then some obscure option ;)
>>
>>Andreas
>
>
> how does it help in using list comprehension, as the ones in the first
> post?
You can nest list comprehension
[ e
for e in (os.path.join(d, x) for x in os.listdir(d))
if os.path.isdir (e)]
You might also want to look at module itertools, which has better
support for transforming and filtering in multiple steps.
Daniel
More information about the Python-list
mailing list