Skip to main content

A library that allows access to Python dictionary values ​​in a more readable way

Project description

dicts_paths_handler

A library that allows access to Python dictionary values in a more readable way by separating keys using dot notation.

Installation

pip install dicts_paths_handler 
#or
py -m pip install dicts_paths_handler

Usage :

First, create a new instance of DictsPathsHandler :

import dicts_paths_handler

your_dict = {
    "language":{
        "availables":("Python", "C", "Java", "C#"),
        "selected":"Python",
    }
}
dph = dicts_paths_handler.DictsPathsHandler(your_dict)

You can access any value in your_dict simply by calling its 'dict_path'. In the following example, we want to access to the value of your_dict['language']['selected']

selected_language = dph.get_value("language.selected")
print(selected_language)

# Should print 'Python'

An InvalidDictPathError exception will be raised if the dict_path is not found or invalid

You can also edit a value. In this example, we want to change the value of your_dict[language]['selected'] :

dph.edit_value("language.selected", "C#")
print(dph.get_value("language.selected")) # Should print 'C#'

An InvalidDictPathError exception will be raised if the dict path is not found or invalid

How does it work ?

Each key of the dict is a part of the dict path, in the normal order of python dict keys : keyA.keyAA.keyAAA.

Infos

This project is developed by SoloEnder

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

dicts_paths_handler-1.3.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dicts_paths_handler-1.3.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file dicts_paths_handler-1.3.0.tar.gz.

File metadata

  • Download URL: dicts_paths_handler-1.3.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for dicts_paths_handler-1.3.0.tar.gz
Algorithm Hash digest
SHA256 c94577dcbb899a891728c7ef664e45d11fda05b45fcb6965c63a4e76c533cc6f
MD5 d1c10119508883ffab44013ff1adb3c9
BLAKE2b-256 a89dc1eec2000af35e26e1a725069eba3d653716dce00ffa8a3d56195ba59bab

See more details on using hashes here.

File details

Details for the file dicts_paths_handler-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dicts_paths_handler-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5567d83588656db89bbcbb2710bf0e4aa9c919b4d173e6329be658979f4c0d1f
MD5 1edf22e9873ef6453cc7a7a637a39018
BLAKE2b-256 fec405983ab9b02e3b6ecd3797dd5d86764966e875a7071187dcc2bd1f7c8918

See more details on using hashes here.

Supported by

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