Skip to content

Commit

Permalink
docs: misc additional examples (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveitaly authored Nov 13, 2023
1 parent 12508ae commit a5427a1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docs/colls.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a5427a1

Please sign in to comment.