# MultiKeyIterDict enhances the capabilities of the standard dictionary by supporting multiple keys, nested searches, and operations such as updates and merges (without loosing data) on dicts
## pip install multikeyiterdict
### Support for Multiple Keys:
MultiKeyIterDict enhances the capabilities of the standard dictionary
by supporting multiple keys, nested searches, and operations such as
updates and merges (without loosing data) on nested data structures.
It is particularly beneficial when working with complex nested
dictionaries or hierarchical data.
### Nested Search:
MultiKeyIterDict provides methods such as nested_value_search
and nested_key_search that allow you to search for values or
keys within the nested structure of the dictionary.
These methods can simplify searching and retrieval of
specific values or keys within complex nested dictionaries.
### Nested Update and Merge:
The nested_update and nested_merge methods enable updating and
merging of dictionaries with nested key-value pairs.
These methods handle the merging of nested data structures seamlessly, providing a convenient way to update or combine
dictionaries with complex hierarchical data.
### Iterable Keys and Values:
The nested_keys, nested_values, and nested_items
methods generate iterable results for the nested keys,
values, and items in the dictionary.
This can be useful when you need to iterate over
or process the nested elements of the dictionary.
```python
from multikeyiterdict import MultiKeyIterDict
dict2 = {2: {"c": 222}, 3: {"d": {3, 6}}}
d = MultiKeyIterDict(dict2)
d[[1, 3, 4, 5, 67]] = 100
print(d[[1, 3]])
dd = {2: {"c": 222}, 3: {"d": {3, 6}}}
print(f"\n\n-----------------------\n{list(d)=}")
print(f"\n\n-----------------------\n{len(d)=}")
print(f"\n\n-----------------------\n{d[1]=}")
print(f"\n\n-----------------------\n{d[1][3]=}")
print(f"\n\n-----------------------\n{d[[1,3]]=}")
d[[23, 4, 5, 323]] = "x"
print(f"\n\n-----------------------\n" "d[[23,4,5,323]] = 'x'={d}" "")
print(f"\n\n-----------------------\n{23 in d=}")
del d[[1, 3]]
print(f"\n\n-----------------------\n" "del d[[1,3]]={d}" "")
del d[1]
print(f"\n\n-----------------------\n" "del d[1]={d}" "")
di2 = d.copy()
print(f"\n\n-----------------------\n{di2 == d=}")
print(f"\n\n-----------------------\n{di2 is d=}")
di2.clear()
print(f"\n\n-----------------------\n" "di2.clear()={di2}" "")
print(f"\n\n-----------------------\n{list(iter(d))=}")
print(f"\n\n-----------------------\n{d.get(2)=}")
print(f"\n\n-----------------------\n{d.get([23,4,5])=}")
print(f"\n\n-----------------------\n{d.items()=}")
print(f"\n\n-----------------------\n{d.keys()=}")
print(f"\n\n-----------------------\n{d.pop(3)=}")
print(f"\n\n-----------------------\n{d.pop([23,4,5])=}")
print(f"\n\n-----------------------\n{d.popitem()=}")
print(f"\n\n-----------------------\nafter d.popitem={d}")
dict2 = {2: {"c": 222}, 3: {"d": {3, 6}}, 4: 3, 33: {33: 2}}
d = MultiKeyIterDict(dict2)
print(f"\n\n-----------------------\n{list(d.reversed())=}")
d.update({4: {44: 4}})
print(f"\n\n-----------------------\nd.update...={d}")
d5 = d | {3: 4}
d |= {3: 4}
print(f"\n\n-----------------------\nd |= {{3:4}}={d}")
print(f"\n\n-----------------------\n{d.to_dict()=}")
#########################################
print(f"\n\n-----------------------\n{list(d.nested_items())=}")
print(f"\n\n-----------------------\n{list(d.nested_values())=}")
print(f"\n\n-----------------------\n{list(d.nested_keys())=}")
print(f"\n\n-----------------------\n{list(d.nested_value_search(4))=}")
d[[1, 3, 4, 5, 67]] = 100
for key in d.nested_key_search(67):
print(key)
for key in d.nested_key_search(4):
print(key)
d7 = d.nested_merge({221: 2, 3: 4})
print(f"\n\n-----------------------\nafter nested merge {d7=}")
d.nested_update({221: 2, 3: 4})
print(f"\n\n-----------------------\nafter nested update {d=}")
#########################################
{4: {5: {67: 100}}}
-----------------------
list(d)=[2, 3, 1]
-----------------------
len(d)=3
-----------------------
d[1]={3: {4: {5: {67: 100}}}}
-----------------------
d[1][3]={4: {5: {67: 100}}}
-----------------------
d[[1,3]]={4: {5: {67: 100}}}
-----------------------
d[[23,4,5,323]] = 'x'={d}
-----------------------
23 in d=True
-----------------------
del d[[1,3]]={d}
-----------------------
del d[1]={d}
-----------------------
di2 == d=True
-----------------------
di2 is d=False
-----------------------
di2.clear()={di2}
-----------------------
list(iter(d))=[2, 3, 23]
-----------------------
d.get(2)={'c': 222}
-----------------------
d.get([23,4,5])={323: 'x'}
-----------------------
d.items()=dict_items([(2, {'c': 222}), (3, {'d': {3, 6}}), (23, {4: {5: {323: 'x'}}})])
-----------------------
d.keys()=dict_keys([2, 3, 23])
-----------------------
d.pop(3)={'d': {3, 6}}
-----------------------
d.pop([23,4,5])={323: 'x'}
-----------------------
d.popitem()=(2, {'c': 222})
-----------------------
after d.popitem={23: {4: {}}}
-----------------------
list(d.reversed())=[33, 4, 3, 2]
-----------------------
d.update...={2: {'c': 222},
3: {'d': {3,
6}},
4: {44: 4},
33: {33: 2}}
-----------------------
d |= {3:4}={2: {'c': 222},
3: 4,
4: {44: 4},
33: {33: 2}}
-----------------------
d.to_dict()={2: {'c': 222}, 3: 4, 4: {44: 4}, 33: {33: 2}}
-----------------------
list(d.nested_items())=[([2, 'c'], 222), ([3], 4), ([4, 44], 4), ([33, 33], 2)]
-----------------------
list(d.nested_values())=[222, 4, 4, 2]
-----------------------
list(d.nested_keys())=[[2, 'c'], [3], [4, 44], [33, 33]]
-----------------------
list(d.nested_value_search(4))=[[3]]
([1, 3, 4, 5, 67], 100)
([4], {44: 4})
([1, 3, 4], {5: {67: 100}})
-----------------------
after nested merge d7={2: {'c': 222}, 3: [4, 4], 4: {44: 4}, 33: {33: 2}, 1: {3: {4: {5: {67: 100}}}}, 221: 2}
-----------------------
after nested update d={1: {3: {4: {5: {67: 100}}}},
2: {'c': 222},
3: [4,
4],
4: {44: 4},
33: {33: 2},
221: 2}
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/multikeyiterdict",
"name": "multikeyiterdict",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "nested",
"author": "Johannes Fischer",
"author_email": "aulasparticularesdealemaosp@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/e1/c8/ca29cc09b7c9364d84b967c695c3d4dd20f44e15ba07850bb3b8c14be6d8/multikeyiterdict-0.12.tar.gz",
"platform": null,
"description": "\r\n# MultiKeyIterDict enhances the capabilities of the standard dictionary by supporting multiple keys, nested searches, and operations such as updates and merges (without loosing data) on dicts\r\n\r\n## pip install multikeyiterdict \r\n\r\n### Support for Multiple Keys: \r\n\r\nMultiKeyIterDict enhances the capabilities of the standard dictionary \r\nby supporting multiple keys, nested searches, and operations such as\r\n updates and merges (without loosing data) on nested data structures. \r\nIt is particularly beneficial when working with complex nested \r\ndictionaries or hierarchical data.\r\n\r\n### Nested Search: \r\n\r\nMultiKeyIterDict provides methods such as nested_value_search \r\nand nested_key_search that allow you to search for values or \r\nkeys within the nested structure of the dictionary. \r\nThese methods can simplify searching and retrieval of \r\nspecific values or keys within complex nested dictionaries.\r\n\r\n### Nested Update and Merge: \r\n\r\nThe nested_update and nested_merge methods enable updating and \r\nmerging of dictionaries with nested key-value pairs. \r\nThese methods handle the merging of nested data structures seamlessly, providing a convenient way to update or combine \r\ndictionaries with complex hierarchical data.\r\n\r\n### Iterable Keys and Values: \r\n\r\nThe nested_keys, nested_values, and nested_items \r\nmethods generate iterable results for the nested keys, \r\nvalues, and items in the dictionary. \r\nThis can be useful when you need to iterate over \r\nor process the nested elements of the dictionary.\r\n\r\n\r\n\r\n\r\n\r\n\r\n```python\r\nfrom multikeyiterdict import MultiKeyIterDict\r\n\r\ndict2 = {2: {\"c\": 222}, 3: {\"d\": {3, 6}}}\r\nd = MultiKeyIterDict(dict2)\r\nd[[1, 3, 4, 5, 67]] = 100\r\nprint(d[[1, 3]])\r\ndd = {2: {\"c\": 222}, 3: {\"d\": {3, 6}}}\r\nprint(f\"\\n\\n-----------------------\\n{list(d)=}\")\r\nprint(f\"\\n\\n-----------------------\\n{len(d)=}\")\r\nprint(f\"\\n\\n-----------------------\\n{d[1]=}\")\r\nprint(f\"\\n\\n-----------------------\\n{d[1][3]=}\")\r\nprint(f\"\\n\\n-----------------------\\n{d[[1,3]]=}\")\r\nd[[23, 4, 5, 323]] = \"x\"\r\nprint(f\"\\n\\n-----------------------\\n\" \"d[[23,4,5,323]] = 'x'={d}\" \"\")\r\nprint(f\"\\n\\n-----------------------\\n{23 in d=}\")\r\ndel d[[1, 3]]\r\nprint(f\"\\n\\n-----------------------\\n\" \"del d[[1,3]]={d}\" \"\")\r\ndel d[1]\r\nprint(f\"\\n\\n-----------------------\\n\" \"del d[1]={d}\" \"\")\r\ndi2 = d.copy()\r\nprint(f\"\\n\\n-----------------------\\n{di2 == d=}\")\r\nprint(f\"\\n\\n-----------------------\\n{di2 is d=}\")\r\ndi2.clear()\r\nprint(f\"\\n\\n-----------------------\\n\" \"di2.clear()={di2}\" \"\")\r\nprint(f\"\\n\\n-----------------------\\n{list(iter(d))=}\")\r\nprint(f\"\\n\\n-----------------------\\n{d.get(2)=}\")\r\nprint(f\"\\n\\n-----------------------\\n{d.get([23,4,5])=}\")\r\nprint(f\"\\n\\n-----------------------\\n{d.items()=}\")\r\nprint(f\"\\n\\n-----------------------\\n{d.keys()=}\")\r\nprint(f\"\\n\\n-----------------------\\n{d.pop(3)=}\")\r\nprint(f\"\\n\\n-----------------------\\n{d.pop([23,4,5])=}\")\r\nprint(f\"\\n\\n-----------------------\\n{d.popitem()=}\")\r\nprint(f\"\\n\\n-----------------------\\nafter d.popitem={d}\")\r\ndict2 = {2: {\"c\": 222}, 3: {\"d\": {3, 6}}, 4: 3, 33: {33: 2}}\r\nd = MultiKeyIterDict(dict2)\r\nprint(f\"\\n\\n-----------------------\\n{list(d.reversed())=}\")\r\nd.update({4: {44: 4}})\r\nprint(f\"\\n\\n-----------------------\\nd.update...={d}\")\r\nd5 = d | {3: 4}\r\nd |= {3: 4}\r\nprint(f\"\\n\\n-----------------------\\nd |= {{3:4}}={d}\")\r\nprint(f\"\\n\\n-----------------------\\n{d.to_dict()=}\")\r\n\r\n#########################################\r\nprint(f\"\\n\\n-----------------------\\n{list(d.nested_items())=}\")\r\nprint(f\"\\n\\n-----------------------\\n{list(d.nested_values())=}\")\r\nprint(f\"\\n\\n-----------------------\\n{list(d.nested_keys())=}\")\r\nprint(f\"\\n\\n-----------------------\\n{list(d.nested_value_search(4))=}\")\r\nd[[1, 3, 4, 5, 67]] = 100\r\nfor key in d.nested_key_search(67):\r\n print(key)\r\n\r\nfor key in d.nested_key_search(4):\r\n print(key)\r\n\r\nd7 = d.nested_merge({221: 2, 3: 4})\r\nprint(f\"\\n\\n-----------------------\\nafter nested merge {d7=}\")\r\n\r\nd.nested_update({221: 2, 3: 4})\r\nprint(f\"\\n\\n-----------------------\\nafter nested update {d=}\")\r\n#########################################\r\n\r\n\r\n\r\n{4: {5: {67: 100}}}\r\n-----------------------\r\nlist(d)=[2, 3, 1]\r\n-----------------------\r\nlen(d)=3\r\n-----------------------\r\nd[1]={3: {4: {5: {67: 100}}}}\r\n-----------------------\r\nd[1][3]={4: {5: {67: 100}}}\r\n-----------------------\r\nd[[1,3]]={4: {5: {67: 100}}}\r\n-----------------------\r\nd[[23,4,5,323]] = 'x'={d}\r\n-----------------------\r\n23 in d=True\r\n-----------------------\r\ndel d[[1,3]]={d}\r\n-----------------------\r\ndel d[1]={d}\r\n-----------------------\r\ndi2 == d=True\r\n-----------------------\r\ndi2 is d=False\r\n-----------------------\r\ndi2.clear()={di2}\r\n-----------------------\r\nlist(iter(d))=[2, 3, 23]\r\n-----------------------\r\nd.get(2)={'c': 222}\r\n-----------------------\r\nd.get([23,4,5])={323: 'x'}\r\n-----------------------\r\nd.items()=dict_items([(2, {'c': 222}), (3, {'d': {3, 6}}), (23, {4: {5: {323: 'x'}}})])\r\n-----------------------\r\nd.keys()=dict_keys([2, 3, 23])\r\n-----------------------\r\nd.pop(3)={'d': {3, 6}}\r\n-----------------------\r\nd.pop([23,4,5])={323: 'x'}\r\n-----------------------\r\nd.popitem()=(2, {'c': 222})\r\n-----------------------\r\nafter d.popitem={23: {4: {}}}\r\n-----------------------\r\nlist(d.reversed())=[33, 4, 3, 2]\r\n-----------------------\r\nd.update...={2: {'c': 222},\r\n 3: {'d': {3,\r\n 6}},\r\n 4: {44: 4},\r\n 33: {33: 2}}\r\n-----------------------\r\nd |= {3:4}={2: {'c': 222},\r\n 3: 4,\r\n 4: {44: 4},\r\n 33: {33: 2}}\r\n-----------------------\r\nd.to_dict()={2: {'c': 222}, 3: 4, 4: {44: 4}, 33: {33: 2}}\r\n-----------------------\r\nlist(d.nested_items())=[([2, 'c'], 222), ([3], 4), ([4, 44], 4), ([33, 33], 2)]\r\n-----------------------\r\nlist(d.nested_values())=[222, 4, 4, 2]\r\n-----------------------\r\nlist(d.nested_keys())=[[2, 'c'], [3], [4, 44], [33, 33]]\r\n-----------------------\r\nlist(d.nested_value_search(4))=[[3]]\r\n([1, 3, 4, 5, 67], 100)\r\n([4], {44: 4})\r\n([1, 3, 4], {5: {67: 100}})\r\n-----------------------\r\nafter nested merge d7={2: {'c': 222}, 3: [4, 4], 4: {44: 4}, 33: {33: 2}, 1: {3: {4: {5: {67: 100}}}}, 221: 2}\r\n-----------------------\r\nafter nested update d={1: {3: {4: {5: {67: 100}}}},\r\n 2: {'c': 222},\r\n 3: [4,\r\n 4],\r\n 4: {44: 4},\r\n 33: {33: 2},\r\n 221: 2}\r\n\r\n\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "MultiKeyIterDict enhances the capabilities of the standard dictionary by supporting multiple keys, nested searches, and operations such as updates and merges (without loosing data) on dicts",
"version": "0.12",
"project_urls": {
"Homepage": "https://github.com/hansalemaos/multikeyiterdict"
},
"split_keywords": [
"nested"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0b2fe75a76a7db2ce8110bca745c29cb67968ecdadbd627fcdd22776ad0185b4",
"md5": "6b78d45ba97f0788d11eef8bca1272a3",
"sha256": "6580192d11dfdb1ba18a80efa3e3ce9b32c6cb51f43933e060162475836f2765"
},
"downloads": -1,
"filename": "multikeyiterdict-0.12-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6b78d45ba97f0788d11eef8bca1272a3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 7843,
"upload_time": "2023-07-10T20:36:38",
"upload_time_iso_8601": "2023-07-10T20:36:38.752795Z",
"url": "https://files.pythonhosted.org/packages/0b/2f/e75a76a7db2ce8110bca745c29cb67968ecdadbd627fcdd22776ad0185b4/multikeyiterdict-0.12-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e1c8ca29cc09b7c9364d84b967c695c3d4dd20f44e15ba07850bb3b8c14be6d8",
"md5": "1417b01dc2d2c063cb400874b3a0c5e2",
"sha256": "179e4dc69dcea3ab5d1425b930cfa21d0bb4a886a16b69c891101e977949c5b9"
},
"downloads": -1,
"filename": "multikeyiterdict-0.12.tar.gz",
"has_sig": false,
"md5_digest": "1417b01dc2d2c063cb400874b3a0c5e2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6285,
"upload_time": "2023-07-10T20:36:40",
"upload_time_iso_8601": "2023-07-10T20:36:40.663203Z",
"url": "https://files.pythonhosted.org/packages/e1/c8/ca29cc09b7c9364d84b967c695c3d4dd20f44e15ba07850bb3b8c14be6d8/multikeyiterdict-0.12.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-10 20:36:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hansalemaos",
"github_project": "multikeyiterdict",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "dict_merger_keep_all",
"specs": []
},
{
"name": "flatten_any_dict_iterable_or_whatsoever",
"specs": []
},
{
"name": "isiter",
"specs": []
},
{
"name": "mymulti_key_dict",
"specs": []
}
],
"lcname": "multikeyiterdict"
}