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.

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.1.0.tar.gz (3.5 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.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dicts_paths_handler-1.1.0.tar.gz
  • Upload date:
  • Size: 3.5 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.1.0.tar.gz
Algorithm Hash digest
SHA256 7b6adaed1025d2aeb49e53dfef24f9f0670cb647aea4258efc19a8895832cb5c
MD5 30a1bd6ffb54ed57074a4eea08ebc178
BLAKE2b-256 b6e267a43a6c1c163561472f01005655c3bac091c0c0a769c68a743136bd027d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dicts_paths_handler-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4d1abfeccb738a82522bf9e63438517d103287b3099e3f0d8150574ded3500d
MD5 a324cefa78c6deb0cd9c868b5f94934e
BLAKE2b-256 25ee2a0b011cf2bfdf3451ed177b45c5e6aaa671a5ff114de45c23b565c5d646

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