Skip to main content

Library to use .json files as configuration objects using namedtuple.

Project description

Library to use .json files as configuration objects using namedtuple.

This library let’s you use .json files as “objects” within your code.


pip install git+


Create a file called config.json (you can change the name to something you like) and add some content to it.

In this demo we add the following data.

  "temperature": 30,
  "screen": {
    "width": 640,
    "height": 480
  "name": null,
  "id": "4V3RYCR4ZY1D"

Now let’s head over Python and test the module and its functions.

Importing the module and loading our .json file.

import utils_config
config = utils_config.load_config(config_file)

Now let’s see what we’ve got in the config variable, serializing it into a dictionary.


Let’s access to its keys/attributes.


Edit the current configuration (Take into account that this function will return a new configuration namedtuple)

config = utils_config.edit_config(config, {"id": "another_id"})

Save the configuration to a file.

utils_config.save_config(config_file, config)


All contributions, pull requests and comments are welcome!

When contributing it is important to test the module in order to make sure everything is working as expected. For that install dependencies to run the tests.

pip install pytest pytest-cov mock pylint

Running tests and see coverage.

py.test --cov -v --cov-config=.coveragerc --cov-report=html

This will generate a report with the coverage which is at 100% now, let’s try to keep it at the same percentage.

Project details

Download files

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

Source Distribution

Utils-Config-1.0.0.tar.gz (10.9 kB view hashes)

Uploaded Source

Built Distribution

Utils_Config-1.0.0-py3-none-any.whl (5.2 kB view hashes)

Uploaded Python 3

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