count

A Python module used for interacting with collections of objects using LINQ syntax


count

count(predicate=None)

Returns the number of elements in the Enumerable instance. This is an executing function.

Parameters

predicate : condition to satisfy as a lambda function. Optional.

Returns

The number of elements in the Enumerable instance as an integer. If a predicate is given, the number of elements in the collection that have satisfied the predicate.

Example


from py_linq import Enumerable

collection = Enumerable([
    {'value': 1},
    {'value': 2},
    {'value': 3}
]).count()
# 3