{"id":24881871,"url":"https://github.com/01joseph-hwang10/dotty-dictionary","last_synced_at":"2025-07-08T18:05:40.671Z","repository":{"id":225861970,"uuid":"766923528","full_name":"01Joseph-Hwang10/dotty-dictionary","owner":"01Joseph-Hwang10","description":"Dictionary wrapper that provides dot notation access to nested dictionaries.","archived":false,"fork":false,"pushed_at":"2024-03-06T06:38:22.000Z","size":106,"stargazers_count":0,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-04T02:45:33.088Z","etag":null,"topics":["dict","dictionary","dot-notation","nested-dictionary","python","utility"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/dotty-dictionary/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/01Joseph-Hwang10.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null}},"created_at":"2024-03-04T11:38:49.000Z","updated_at":"2024-03-09T07:54:36.000Z","dependencies_parsed_at":"2024-03-04T18:38:36.518Z","dependency_job_id":null,"html_url":"https://github.com/01Joseph-Hwang10/dotty-dictionary","commit_stats":null,"previous_names":["01joseph-hwang10/dotty-dictionary"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/01Joseph-Hwang10/dotty-dictionary","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/01Joseph-Hwang10%2Fdotty-dictionary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/01Joseph-Hwang10%2Fdotty-dictionary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/01Joseph-Hwang10%2Fdotty-dictionary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/01Joseph-Hwang10%2Fdotty-dictionary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/01Joseph-Hwang10","download_url":"https://codeload.github.com/01Joseph-Hwang10/dotty-dictionary/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/01Joseph-Hwang10%2Fdotty-dictionary/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264320949,"owners_count":23590561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dict","dictionary","dot-notation","nested-dictionary","python","utility"],"created_at":"2025-02-01T12:14:12.359Z","updated_at":"2025-07-08T18:05:40.650Z","avatar_url":"https://github.com/01Joseph-Hwang10.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dotty-dictionary\n\n[![PyPI version](https://badge.fury.io/py/dotty-dictionary.svg)](https://pypi.org/project/dotty-dictionary)\n[![Testsuite](https://github.com/01Joseph-Hwang10/dotty-dictionary/workflows/Test%20and%20Lint/badge.svg)](https://github.com/01Joseph-Hwang10/dotty-dictionary/actions?query=workflow%3A\"Test+and+Lint\")\n[![Python version](https://img.shields.io/pypi/pyversions/dotty-dictionary.svg)](https://pypi.org/project/dotty-dictionary)\n[![Project Status](https://img.shields.io/pypi/status/dotty-dictionary.svg)](https://pypi.org/project/dotty-dictionary/)\n[![Supported Interpreters](https://img.shields.io/pypi/implementation/dotty-dictionary.svg)](https://pypi.org/project/dotty-dictionary/)\n[![License](https://img.shields.io/pypi/l/dotty-dictionary.svg)](https://github.com/pawelzny/dotty-dictionary/blob/master/LICENSE)\n\n`dotty-dictionary` is a Python library that provides a dictionary-like object that allows you to access nested dictionaries using dot notation.\n\n`dotty-dictionary` is a fork of [pawelzny/dotty_dict](https://github.com/pawelzny/dotty_dict) that provides additional features and improvements.\n\n## Installation\n\n```bash\npip install dotty-dictionary\n```\n\n- Package: \u003chttps://pypi.org/project/dotty-dictionary\u003e\n- Source: \u003chttps://github.com/01Joseph-Hwang10/dotty-dictionary\u003e\n\n## Features\n\n### Provides dot notation acccess to dictionary objects\n\nIt provides a simple wrapper around python dictionary and dict like `Mapping` objects. \nYou can access deeply nested keys with dot notation.\n\n```py\nfrom dotty_dictionary import dotty\ndot = dotty({\"deeply\": {\"nested\": {\"key\": \"value\"}}})\ndot['deeply.nested.key']\n'value'\n```\n\n### Exposes all dictionary methods (`.get`, `.pop`, `.keys`, ...)\n\nYou can use all dictionary methods like `.get`, `.pop`, `.keys` and other.\n\n```py\nfrom dotty_dictionary import dotty\ndot = dotty({\"deeply\": {\"nested\": {\"key\": \"value\"}}})\n\n# View methods\nlist(dot.keys()) # [\"deeply\"]\nlist(dot.values()) # [{\"nested\": {\"key\": \"value\"}}]\nlist(dot.items()) #[(\"deeply\", {\"nested\": {\"key\": \"value\"}})]\n\n# `.update`\ndot.update({\"other\": \"value\"})\ndot\nDot(dictionary={'deeply': {'nested': {'key': 'value'}}, 'other': 'value'}, separator='.', esc_char='\\\\')\n\n# `.pop`: Pops nested keys\ndot.pop(\"deeply.nested.key\")\n\"value\"\n\n# `.copy`\ndot is not dot.copy()\nTrue\n```\n\n### Dot notation access support for list objects\n\nYou can access dicts in lists by index like: `dot['parents.0.first_name']`.\nIt also supports multidimensional lists.\n\n```py\nfrom dotty_dictionary import dotty\ndot = dotty({\"parents\": [{\"first_name\": \"John\"}, {\"first_name\": \"Jane\"}]})\ndot['parents.0.first_name']\n'John'\n\ndot = dotty({\"matrix\": [[1, 2, 3], [4, 5, 6], [7, 8, 9]]})\ndot['matrix.1.1']\n5\n```\n\n\u003e [!NOTE]\\\n\u003e Using integer in dictionary keys will be treated as embedded list index.\n\n\n### Support for accessing lists with slices\n\nYou can access lists with slices like: `dot['parents.0:2']`.\n\n```py\nfrom dotty_dictionary import dotty\ndot = dotty({\"parents\": [{\"first_name\": \"John\"}, {\"first_name\": \"Jane\"}, {\"first_name\": \"Doe\"}]})\ndot['parents.0:2']\n[{\"first_name\": \"John\"}, {\"first_name\": \"Jane\"}]\n\ndot['parents.:']\n[{\"first_name\": \"John\"}, {\"first_name\": \"Jane\"}, {\"first_name\": \"Doe\"}]\n```\n\n### Flattening and Unflattening\n\nYou can utilize `to_flat_dict` and `from_flat_dict` to convert dotty to and from flat dictionary.\n\n```py\nfrom dotty_dictionary import Dotty\ndot = Dotty.from_flat_dict({'very.deeply.nested.thing': 'spam', 'very.deeply.spam': 'indeed'})\ndot\nDotty(dictionary={'very': {'deeply': {'nested': {'thing': 'spam'}, 'spam': 'indeed'}}}, separator='.', esc_char='\\\\')\n\ndot.to_flat_dict()\n{'very.deeply.nested.thing': 'spam', 'very.deeply.spam': 'indeed'}\n```\n\n### Custom Types \u0026\u0026 Encoders\n\nBy default, `dotty-dictionary` only considers `dict` as a mapping type, and `list` as a sequence type and will provide a dot notation access for them. However, you can also provide custom types to be considered as mapping or sequence types.\n\n```py\nfrom collections.abc import MutableMapping\nfrom dataclasses import dataclass\nfrom dotty_dictionary import Dotty, DottyEncoder\n\n\n@dataclass\nclass User(MutableMapping):\n    name: str\n    age: int\n\n    # Implementations are skipped for brevity\n\nclass CustomJSONEncoder(DottyEncoder):\n    def default(self, obj):\n        if isinstance(obj, User):\n            return {\"name\": obj.name, \"age\": obj.age}\n        return super().default(obj)\n\ndictionary = {\n    \"a\": { \n        \"b\": { \"c\": 1, \"d\": 2 },\n        \"e\": (3, {\"f\": 4}, (5, 6, 7)), # Has Tuple\n    },\n    \"g\": 8,\n    \"h\": User(name=\"John\", age=25), # Has Custom Dataclass\n}\ndot = Dotty(\n    dictionary,\n    mapping_types=(dict, User),\n    sequence_types=(list, tuple),\n    json_encoder=CustomJSONEncoder,\n)\n\ndot[\"a.e.1.f\"]\n4\n\ndot[\"h.name\"]\n\"John\"\n\ndot[\"h.age\"] = 26\ndot[\"h.age\"]\n26\n```\n\nFull example can be found on [tests/test_dotty_custom_types.py](https://github.com/01Joseph-Hwang10/dotty-dictionary/tree/master/tests/test_dotty_custom_types.py)\n\n## More Examples\n\nMore examples can be found in the [examples](https://github.com/01Joseph-Hwang10/dotty-dictionary/tree/master/examples) and [tests](https://github.com/01Joseph-Hwang10/dotty-dictionary/tree/master/tests) directory.\n\n## Contributing\n\nAny contribution is welcome! Check out [CONTRIBUTING.md](https://github.com/01Joseph-Hwang10/dotty-dictionary/blob/master/.github/CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](https://github.com/01Joseph-Hwang10/dotty-dictionary/blob/master/.github/CODE_OF_CONDUCT.md) for more information on how to get started.\n\n## License\n\n`dotty-dictionary` is licensed under a [MIT License](https://github.com/01Joseph-Hwang10/dotty-dictionary/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F01joseph-hwang10%2Fdotty-dictionary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F01joseph-hwang10%2Fdotty-dictionary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F01joseph-hwang10%2Fdotty-dictionary/lists"}