On 6/22/2015 9:32 PM, Paul Rubin wrote:
Travis Griggs <travisgri...@gmail.com> 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 functionalist would prefer it to the obvious 3-line version with a for statement.

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

itertools callables all produce iterators. The above only consumes an iterable.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to