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:
russellballestrini 2019-05-21 10:23:00 -04:00
parent 8cec46c76e
commit 9348af1790
7 changed files with 361 additions and 387 deletions

View file

@ -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