Deep()
Find a dictionary in a list of dictionaries by value.
Deep()
returns a dictionary from a list of dictionaries by value. This can be useful when you need to pick out e.g. a product by id from a list of products represented by dictionaries.
Usage
deep(..., search requirements)
Parameters:
A list.
That contains only ditionaries.
Example
products = [
{
id: 1,
title: 'Product 1'
},
{
id: 2,
title: 'Product 2'
},
{
id: 3,
title: 'Product 3'
}
]
# Get the product with the id of 2.
selection = deep(products, {id: 2})
Last updated