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.0.1.tar.gz (3.4 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.0.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dicts_paths_handler-1.0.1.tar.gz
  • Upload date:
  • Size: 3.4 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.0.1.tar.gz
Algorithm Hash digest
SHA256 56e82cca249bffe1c160193e65ba667a8b6d72080e9cea44b21cf00a050bc697
MD5 e0a797a97cd009cdede1f359e12037d7
BLAKE2b-256 c70b00b4b7c3fc08ef47ca2be0907475c41dd0b58868e9235b1edb42307a81b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dicts_paths_handler-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d5132e406b37324dc53d97aadaead08efba06415c5f62c277e00d95cebbc7485
MD5 00eb108b81035385ba23ddc4a2ea52e8
BLAKE2b-256 f0091a371fd95926a512d3828a6719e24b043cc26a2735400aed8b7ae5798124

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