Skip to main content

A Python module who does recursive update work on 2 dicts.

Project description

https://travis-ci.org/Maples7/dict-recursive-update.svg?branch=master https://img.shields.io/pypi/v/dict-recursive-update.svg

A Python module who does recursive update work on 2 dicts.

Usage

Installation

pip install dict-recursive-update

Examples

>>> from dict_recursive_update import recursive_update

>>> recursive_update({'a': {'b': 2}}, {'a': {'b': 3, 'd': 4}, 'e': 5})
{'a': {'b': 3, 'd': 4}, 'e': 5}

>>> recursive_update('a', 'b')
Traceback (most recent call last):
    ...
TypeError: Params of recursive_update should be dicts

>>> recursive_update({'a': [1]}, {'a': [2], 'c': {'d': {'c': 3}}})
{'a': [2], 'c': {'d': {'c': 3}}}

>>> recursive_update({'a': {'c': 1, 'd': {}}, 'b': 4}, {'b': 5})
{'a': {'c': 1, 'd': {}}, 'b': 5}

>>> recursive_update({'a': {'c': 1, 'd': {}}, 'b': 4}, {'a': 2})
{'a': 2, 'b': 4}

Why?

This is originally designed for merge multiple configurations in different running environment such as production or stage.

As a node.js developer, package config and lodash are very handy for me. This package is the base of a python-version config package.

In a normal project, there is usually a copy of default configuration, but when we deploy it, some configurations differ from default ones like database address. So a handy configuration-loading package is supposed to load right configurations according to the running environment.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

dict_recursive_update-1.0.1-py2.py3-none-any.whl (4.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file dict_recursive_update-1.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for dict_recursive_update-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 24bfdd88ff2bf7bd85870b8c65918002638888a790f7453865bdce6f3b83f8ff
MD5 8e9d6145370f3b0050540ac5b6a1523e
BLAKE2b-256 88402cb6ba8f04590f41bb43f5ddb50217705aa6fcb9499f424160259e7e2b8c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page