Simplest/Idiomatic way to count files in a directory (using pathlib)

Paul Rubin no.email at nospam.invalid
Mon Jun 22 21:32:52 EDT 2015


Travis Griggs <travisgriggs at gmail.com> writes:
> The following seems to obtuse/clever for its own good:
>     return sum(1 for _ in self.path.iterdir())

I've generally done something like that.  I suppose it could be added to
itertools.



More information about the Python-list mailing list