From d065138faa14c853cd4fa924628cd3ce51798f7e Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Sat, 11 Nov 2023 14:34:28 -0700 Subject: [PATCH] docs: misc additional examples --- docs/colls.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/colls.rst b/docs/colls.rst index 1bf0eff..a0119a4 100644 --- a/docs/colls.rst +++ b/docs/colls.rst @@ -174,11 +174,14 @@ Dict utils .. function:: omit(mapping, keys) - Returns a copy of ``mapping`` with ``keys`` omitted. Preserves collection type:: + Returns a copy of ``mapping`` with ``keys`` omitted. Each key of `mapping` is checked if it is contained with `keys`, so a string and an array could be used. Preserves collection type:: omit({'a': 1, 'b': 2, 'c': 3}, 'ac') # -> {'b': 2} + omit({'a': 1, 'b': 2, 'c': 3}, ['a', 'c']) + # -> {'b': 2} + .. function:: zip_values(*dicts) @@ -281,6 +284,11 @@ Data manipulation map(operator.itemgetter(key), mappings) + e.g. extracting a key from a list of dictionaries:: + + lpluck('name', [{'name': 'John'}, {'name': 'Mary'}]) + # -> ['John', 'Mary'] + .. function:: pluck_attr(attr, objects) lpluck_attr(attr, objects)