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.2.0.tar.gz (4.0 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.2.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dicts_paths_handler-1.2.0.tar.gz
  • Upload date:
  • Size: 4.0 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.2.0.tar.gz
Algorithm Hash digest
SHA256 9cca295e7691676765d88d70674b965beb58df6746e74a46c9a871716e836437
MD5 1b012390f72cd63580516edb9b5e1632
BLAKE2b-256 8f0c18c43c74e2d71e2abce5355120d61add4a55d5dbc9fba8a9f90b3e3304d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dicts_paths_handler-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de987d2ebea2e7c144a59b98411bd112f0ccb7e4a3a40bff1e504afedfab8a32
MD5 09e97e4344e3098082ab6515ca77cd01
BLAKE2b-256 106937dd92f89a49c1c7e3e5e773ae08363e1e2ef3ed66a443d451e78599a0d1

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