Set of utilities and accessory methods to work with Python dicts.
Project description
# dict-utils ![License MIT](https://go-shields.herokuapp.com/license-MIT-blue.png)
[![Travis-CI Status](https://secure.travis-ci.org/glowdigitalmedia/dict-utils.png?branch=master)](http://travis-ci.org/#!/glowdigitalmedia/dict-utils)
[![Coverage Status](https://coveralls.io/repos/glowdigitalmedia/dict-utils/badge.png?branch=master)](https://coveralls.io/r/glowdigitalmedia/dict-utils?branch=master)
[![PyPI version](https://badge.fury.io/py/dict-utils.svg)](http://badge.fury.io/py/dict-utils)
dict-utils is a set of utilities and accessory methods usable
with Python dicts.
## Examples
1. Search for a value in a dictionary, passing a key:
```python
from dict_utils import dict_utils
dict_1 = {'first_level': {'second_level': {'name': 'Joe', 'age': 30}}}
found_value = dict_utils.dict_search_value(dict_1, 'name')
```
**found_value** will contain **'Joe'**
2. Compare two different dictionaries having the same keys
```python
from dict_utils import dict_utils
dict_1 = {'first_level': {'second_level': {'name': 'Joe', 'age': 30}}}
dict_2 = {'level_1': {'level_2': {'name': 'Joe', 'age': 30}}}
dict_utils.compare_assert_dicts(self, ['name', 'age'], dict_1, dict_2)
```
## Running Tests
```
python setup.py test
```
[![Travis-CI Status](https://secure.travis-ci.org/glowdigitalmedia/dict-utils.png?branch=master)](http://travis-ci.org/#!/glowdigitalmedia/dict-utils)
[![Coverage Status](https://coveralls.io/repos/glowdigitalmedia/dict-utils/badge.png?branch=master)](https://coveralls.io/r/glowdigitalmedia/dict-utils?branch=master)
[![PyPI version](https://badge.fury.io/py/dict-utils.svg)](http://badge.fury.io/py/dict-utils)
dict-utils is a set of utilities and accessory methods usable
with Python dicts.
## Examples
1. Search for a value in a dictionary, passing a key:
```python
from dict_utils import dict_utils
dict_1 = {'first_level': {'second_level': {'name': 'Joe', 'age': 30}}}
found_value = dict_utils.dict_search_value(dict_1, 'name')
```
**found_value** will contain **'Joe'**
2. Compare two different dictionaries having the same keys
```python
from dict_utils import dict_utils
dict_1 = {'first_level': {'second_level': {'name': 'Joe', 'age': 30}}}
dict_2 = {'level_1': {'level_2': {'name': 'Joe', 'age': 30}}}
dict_utils.compare_assert_dicts(self, ['name', 'age'], dict_1, dict_2)
```
## Running Tests
```
python setup.py test
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dict-utils-0.1.2.tar.gz
(2.6 kB
view details)
File details
Details for the file dict-utils-0.1.2.tar.gz
.
File metadata
- Download URL: dict-utils-0.1.2.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5bbbc1da14597dda251e19d0b2179cd06f11e122489126077667d06c14606c1 |
|
MD5 | fe1d188f7fcfae315f8d383e57d8b274 |
|
BLAKE2b-256 | 07f91860c89321923547ed7a66109d0cd05b6f36905cc0a38d595787895d11ef |