On 6/22/2015 9:32 PM, Paul Rubin wrote:
Travis Griggs writes:
The following seems to obtuse/clever for its own good:
return sum(1 for _ in self.path.iterdir())
I disagree. For one who understands counting and Python, this is a
direct way to define the count of a finite iterable. A fun
Travis Griggs wrote:
> Subject nearly says it all.
>
> If i’m using pathlib, what’s the simplest/idiomatic way to simply count
> how many files are in a given directory?
>
> I was surprised (at first) when
>
> len(self.path.iterdir())
>
> I don’t say anything on the in the .stat() object t
I use len(list(self.path.iterdir()))
You get an extra list created in there. Do you care?
Laura
--
https://mail.python.org/mailman/listinfo/python-list
Travis Griggs 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.
--
https://mail.python.org/mailman/listinfo/python-list
On Mon, Jun 22, 2015 at 4:33 PM, Travis Griggs wrote:
>
>
> Subject nearly says it all.
>
> If i’m using pathlib, what’s the simplest/idiomatic way to simply count how
> many files are in a given directory?
>
> I was surprised (at first) when
>
>len(self.path.iterdir())
>
> didn’t work.
len
Subject nearly says it all.
If i’m using pathlib, what’s the simplest/idiomatic way to simply count how
many files are in a given directory?
I was surprised (at first) when
len(self.path.iterdir())
didn’t work.
I don’t see anything in the .stat() object that helps me.
I could of course
Subject nearly says it all.
If i’m using pathlib, what’s the simplest/idiomatic way to simply count how
many files are in a given directory?
I was surprised (at first) when
len(self.path.iterdir())
I don’t say anything on the in the .stat() object that helps me.
I could of course do the 4