punktdict


Namepunktdict JSON
Version 0.11 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/punktdict
Summarya dict with key attributes
upload_time2023-07-12 12:07:24
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords dict attributes
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# a dict with key attributes 

## pip install punktdict 

This module provides the `PunktDict` class, which is a subclass of dict with additional functionality for handling nested dictionaries. 
It also provides some configuration options through the `dictconfig` object.


```python
import sys
from punktdict import PunktDict, dictconfig, convert_to_dict

# Configure PunktDict behavior
dictconfig.allow_nested_attribute_creation = True
dictconfig.allow_nested_key_creation = True
dictconfig.convert_all_dicts_recursively = True
PunktDict._check_forbidden_key = (
    lambda self, x: (x.startswith("_ipython") or x == "_repr_mimebundle_")
)

# Create a PunktDict object
d = PunktDict({'popeye': {'mole': {'bole': 'dolle'}}})

# Access and modify nested dictionary values
d['hallo']['baba'] = 11
d.lll.ddd.xxx = 333

# Update PunktDict with new data
d.update({'rrrx': {'xxxxx': 'bbbb'}})
d.rrrx.xxxxxxx = []
d.rrrx.xxxxxxx.append(3)

# Access nested dictionary values using attribute syntax
d['gggg']['xxxxx']['tttt'] = 12
print(d.gggg.xxxxx.tttt)

# Convert PunktDict to a regular dictionary
di = convert_to_dict(d)
---------------

Attributes:
-----------
- allow_nested_attribute_creation: A boolean flag indicating whether PunktDict allows creation of nested attributes. Default is True.
- allow_nested_key_creation: A boolean flag indicating whether PunktDict allows creation of nested keys. Default is True.
- convert_all_dicts_recursively: A boolean flag indicating whether PunktDict recursively converts all nested dictionaries to PunktDict objects. Default is True.

Classes:
--------
- PunktDict: A subclass of dict with additional functionality for handling nested dictionaries.

Functions:
----------
- check_if_compatible_dict: Checks if an object is a compatible dictionary based on its type and attributes.
- convert_to_dict: Recursively converts a PunktDict object or a compatible dictionary to a regular dictionary.

Note:
-----
The `PunktDict` class overrides several methods and provides additional methods to handle nested dictionaries. The configuration options can be modified through the `dictconfig` object. The `convert_to_dict` function can be used to convert a PunktDict object or a compatible dictionary to a regular dictionary.

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/punktdict",
    "name": "punktdict",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "dict,attributes",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f9/cf/c4cd7742e4f636714d4cf91e1d269df0f679161f325ada06dfdc6fc7d125/punktdict-0.11.tar.gz",
    "platform": null,
    "description": "\r\n# a dict with key attributes \r\n\r\n## pip install punktdict \r\n\r\nThis module provides the `PunktDict` class, which is a subclass of dict with additional functionality for handling nested dictionaries. \r\nIt also provides some configuration options through the `dictconfig` object.\r\n\r\n\r\n```python\r\nimport sys\r\nfrom punktdict import PunktDict, dictconfig, convert_to_dict\r\n\r\n# Configure PunktDict behavior\r\ndictconfig.allow_nested_attribute_creation = True\r\ndictconfig.allow_nested_key_creation = True\r\ndictconfig.convert_all_dicts_recursively = True\r\nPunktDict._check_forbidden_key = (\r\n    lambda self, x: (x.startswith(\"_ipython\") or x == \"_repr_mimebundle_\")\r\n)\r\n\r\n# Create a PunktDict object\r\nd = PunktDict({'popeye': {'mole': {'bole': 'dolle'}}})\r\n\r\n# Access and modify nested dictionary values\r\nd['hallo']['baba'] = 11\r\nd.lll.ddd.xxx = 333\r\n\r\n# Update PunktDict with new data\r\nd.update({'rrrx': {'xxxxx': 'bbbb'}})\r\nd.rrrx.xxxxxxx = []\r\nd.rrrx.xxxxxxx.append(3)\r\n\r\n# Access nested dictionary values using attribute syntax\r\nd['gggg']['xxxxx']['tttt'] = 12\r\nprint(d.gggg.xxxxx.tttt)\r\n\r\n# Convert PunktDict to a regular dictionary\r\ndi = convert_to_dict(d)\r\n---------------\r\n\r\nAttributes:\r\n-----------\r\n- allow_nested_attribute_creation: A boolean flag indicating whether PunktDict allows creation of nested attributes. Default is True.\r\n- allow_nested_key_creation: A boolean flag indicating whether PunktDict allows creation of nested keys. Default is True.\r\n- convert_all_dicts_recursively: A boolean flag indicating whether PunktDict recursively converts all nested dictionaries to PunktDict objects. Default is True.\r\n\r\nClasses:\r\n--------\r\n- PunktDict: A subclass of dict with additional functionality for handling nested dictionaries.\r\n\r\nFunctions:\r\n----------\r\n- check_if_compatible_dict: Checks if an object is a compatible dictionary based on its type and attributes.\r\n- convert_to_dict: Recursively converts a PunktDict object or a compatible dictionary to a regular dictionary.\r\n\r\nNote:\r\n-----\r\nThe `PunktDict` class overrides several methods and provides additional methods to handle nested dictionaries. The configuration options can be modified through the `dictconfig` object. The `convert_to_dict` function can be used to convert a PunktDict object or a compatible dictionary to a regular dictionary.\r\n\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "a dict with key attributes",
    "version": "0.11",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/punktdict"
    },
    "split_keywords": [
        "dict",
        "attributes"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8adb506414fd5207c9d680b590fe6fd2776e5ef4c577901227d95f83f72d29da",
                "md5": "de91f49c8b67ac9e42ca2bc6f4b17732",
                "sha256": "c7e73cdced9fe34d93f55443b9719c1fcf037d3124e64dfcfb4d112426fbe8f0"
            },
            "downloads": -1,
            "filename": "punktdict-0.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "de91f49c8b67ac9e42ca2bc6f4b17732",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6049,
            "upload_time": "2023-07-12T12:07:22",
            "upload_time_iso_8601": "2023-07-12T12:07:22.984467Z",
            "url": "https://files.pythonhosted.org/packages/8a/db/506414fd5207c9d680b590fe6fd2776e5ef4c577901227d95f83f72d29da/punktdict-0.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f9cfc4cd7742e4f636714d4cf91e1d269df0f679161f325ada06dfdc6fc7d125",
                "md5": "89415f50161d5abee349200000b604a0",
                "sha256": "e46317d633ab927165aa7e1df82a1ddfcf44068bd1cfb02687c1335248129a00"
            },
            "downloads": -1,
            "filename": "punktdict-0.11.tar.gz",
            "has_sig": false,
            "md5_digest": "89415f50161d5abee349200000b604a0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4690,
            "upload_time": "2023-07-12T12:07:24",
            "upload_time_iso_8601": "2023-07-12T12:07:24.489771Z",
            "url": "https://files.pythonhosted.org/packages/f9/cf/c4cd7742e4f636714d4cf91e1d269df0f679161f325ada06dfdc6fc7d125/punktdict-0.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-12 12:07:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "punktdict",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "punktdict"
}
        
Elapsed time: 0.10069s