modified: README.rst
modified: nested_lookup/__init__.py modified: nested_lookup/lookup_api.py modified: nested_lookup/nested_lookup.py modified: setup.py modified: test_lookup_api.py modified: test_nested_lookup.py
This commit is contained in:
parent
8cec46c76e
commit
9348af1790
7 changed files with 361 additions and 387 deletions
16
README.rst
16
README.rst
|
|
@ -89,21 +89,21 @@ In this example we can be sure that only int will be passed, in production you s
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
>>> def callback(data):
|
||||
>>> return data + 10 # add 10 to every taco prize
|
||||
>>> def callback(data):
|
||||
>>> return data + 10 # add 10 to every taco prize
|
||||
|
||||
The alter-version only works for scalar input (one dict), if you need to adress a list of dicts, you have to
|
||||
manually iterate over those and pass them to nested_update one by one
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
>>> out =[]
|
||||
>>> for elem in document:
|
||||
>>> altered_document = nested_alter(elem,"taco", callback)
|
||||
>>> out.append(altered_document)
|
||||
>>> out =[]
|
||||
>>> for elem in document:
|
||||
>>> altered_document = nested_alter(elem,"taco", callback)
|
||||
>>> out.append(altered_document)
|
||||
|
||||
>>> print(out)
|
||||
[ { 'taco' : 52 } , { 'salsa' : [ { 'burrito' : { 'taco' : 79 } } ] } ]
|
||||
>>> print(out)
|
||||
[ { 'taco' : 52 } , { 'salsa' : [ { 'burrito' : { 'taco' : 79 } } ] } ]
|
||||
|
||||
>>> from nested_lookup import get_all_keys
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue