{"id":13738461,"url":"https://github.com/drgrib/dotmap","last_synced_at":"2025-05-15T12:06:38.622Z","repository":{"id":36260408,"uuid":"40564835","full_name":"drgrib/dotmap","owner":"drgrib","description":"Dot access dictionary with dynamic hierarchy creation and ordered iteration","archived":false,"fork":false,"pushed_at":"2024-01-23T18:20:01.000Z","size":131,"stargazers_count":477,"open_issues_count":13,"forks_count":43,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-05-09T20:52:17.950Z","etag":null,"topics":["dictionaries","maps","python","python2","python3"],"latest_commit_sha":null,"homepage":"","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/drgrib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"FelixSchwarz, drgrib"}},"created_at":"2015-08-11T20:56:21.000Z","updated_at":"2025-05-07T17:53:11.000Z","dependencies_parsed_at":"2024-01-23T19:31:17.348Z","dependency_job_id":null,"html_url":"https://github.com/drgrib/dotmap","commit_stats":{"total_commits":241,"total_committers":20,"mean_commits":12.05,"dds":"0.24896265560165975","last_synced_commit":"c7a778a95a01a7a0fd2f816a07c62de2478260c6"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drgrib%2Fdotmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drgrib%2Fdotmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drgrib%2Fdotmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drgrib%2Fdotmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drgrib","download_url":"https://codeload.github.com/drgrib/dotmap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253377576,"owners_count":21898939,"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":["dictionaries","maps","python","python2","python3"],"created_at":"2024-08-03T03:02:23.136Z","updated_at":"2025-05-15T12:06:33.565Z","avatar_url":"https://github.com/drgrib.png","language":"Python","readme":"# DotMap\n\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate?business=N2GLXLS5KBFBY\u0026item_name=Chris+Redford\u0026currency_code=USD)\n\n# Install\n\n```\npip3 install dotmap\n```\n\n## Upgrade\n\nGet updates for current installation\n\n```\npip3 install --upgrade dotmap\n```\n\n# Features\n\n`DotMap` is a dot-access `dict` subclass that\n\n-   has dynamic hierarchy creation (autovivification)\n-   can be initialized with keys\n-   easily initializes from `dict`\n-   easily converts to `dict`\n-   is ordered by insertion\n\nThe key feature is exactly what you want: dot-access\n\n```python\nfrom dotmap import DotMap\nm = DotMap()\nm.name = 'Joe'\nprint('Hello ' + m.name)\n# Hello Joe\n```\n\nHowever, `DotMap` is a `dict` and you can treat it like a `dict` as needed\n\n```python\nprint(m['name'])\n# Joe\nm.name += ' Smith'\nm['name'] += ' Jr'\nprint(m.name)\n# Joe Smith Jr\n```\n\nIt also has fast, automatic hierarchy (which can be deactivated by initializing with `DotMap(_dynamic=False)`)\n\n```python\nm = DotMap()\nm.people.steve.age = 31\n```\n\nAnd key initialization\n\n```python\nm = DotMap(a=1, b=2)\n```\n\nYou can initialize it from `dict` and convert it to `dict`\n\n```python\nd = {'a':1, 'b':2}\n\nm = DotMap(d)\nprint(m)\n# DotMap(a=1, b=2)\n\nprint(m.toDict())\n# {'a': 1, 'b': 2}\n```\n\nAnd it has iteration that is ordered by insertion\n\n```python\nm = DotMap()\n\nm.people.john.age = 32\nm.people.john.job = 'programmer'\nm.people.mary.age = 24\nm.people.mary.job = 'designer'\nm.people.dave.age = 55\nm.people.dave.job = 'manager'\n\nfor k, v in m.people.items():\n\tprint(k, v)\nprint\n\n# john DotMap(age=32, job='programmer')\n# mary DotMap(age=24, job='designer')\n# dave DotMap(age=55, job='manager')\n```\n\nIt also has automatic counter initialization\n\n```python\nm = DotMap()\nfor i in range(7):\n\tm.counter += 1\nprint(m.counter)\n# 7\n```\n\nAnd automatic addition initializations of any other type\n\n```python\nm = DotMap()\nm.quote += 'lions'\nm.quote += ' and tigers'\nm.quote += ' and bears'\nm.quote += ', oh my'\nprint(m.quote)\n# lions and tigers and bears, oh my\n```\n\nThere is also built-in `pprint` as `dict` or `json` for debugging a large `DotMap`\n\n```python\nm.pprint()\n# {'people': {'dave': {'age': 55, 'job': 'manager'},\n#             'john': {'age': 32, 'job': 'programmer'},\n#             'mary': {'age': 24, 'job': 'designer'}}}\nm.pprint(pformat='json')\n# {\n#     \"people\": {\n#         \"dave\": {\n#\t      \"age\": 55,\n#\t      \"job\": \"manager\"\n# \t  },\n# \t  \"john\": {\n#\t      \"age\": 32,\n#\t      \"job\": \"programmer\"\n# \t  },\n# \t  \"mary\": {\n#\t      \"age\": 24,\n#\t      \"job\": \"designer\"\n# \t  }\n#     }\n# }\n```\n\nAnd many other features involving dots and dictionaries that will be immediately intuitive when used.\n","funding_links":["https://github.com/sponsors/FelixSchwarz, drgrib","https://www.paypal.com/donate?business=N2GLXLS5KBFBY\u0026item_name=Chris+Redford\u0026currency_code=USD"],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrgrib%2Fdotmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrgrib%2Fdotmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrgrib%2Fdotmap/lists"}