https://github.com/nick-at-dave/DotDict Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Resources + Customer Stories + White papers, Ebooks, Webinars + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. {{ message }} nick-at-dave / DotDict Public * Notifications * Fork 0 * Star 23 A simple Python library to make chained attributes possible. License GPL-3.0 license 23 stars 0 forks Activity Star Notifications * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights nick-at-dave/DotDict This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 1 branch 1 tag Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/n] Use Git or checkout with SVN using the web URL. [gh repo clone nick-a] Work fast with our official CLI. Learn more about the CLI. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @nick-at-dave nick-at-dave removed unnecessarily overloaded func ... 7ca7dd5 Aug 2, 2023 removed unnecessarily overloaded func 7ca7dd5 Git stats * 16 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github/workflows Create python-publish.yml August 2, 2023 18:10 LICENSE Initial commit August 2, 2023 15:59 README.md updated readme to include pypi package August 2, 2023 18:27 dotdict.py removed unnecessarily overloaded func August 2, 2023 18:37 pyproject.toml removed unnecessarily overloaded func August 2, 2023 18:37 setup.py migrated to pyproject.tom August 2, 2023 16:38 View code DotDict Why? Installation Usage README.md DotDict A simple Python library that builds upon argparse.Namespace to make chained attributes possible. Why? Configs of all kinds follow a dict-like structure. However, nobody likes the dict["key"] syntax. We all much prefer the dict.key syntax. There are a number of workarounds for this, including easydict or argparse.Namespace (upon which this library is based). The downside of these libraries, though, is that when you want to start a new level, you must explicitly define it first. For example: config = edict() config.host = 'localhost' config.users = edict() # or {} config.users.foo = 'bar' This is ugly. Wouldn't you much prefer the following syntax? config = dd() config.host = 'localhost' config.users.foo = 'bar' Installation Installation is simple: pip install attr-dot-dict. Alternatively: pip install . from the root of the repository. Usage Usage is equally as simple: from dotdict import DotDict as dd x = dd() x.a.b.c = 1 x.a.d = 2 x.a.b.e = 3 print(x) # DotDict(a=DotDict(b=DotDict(c=1, e=3), d=2)) print(vars(x)) # {'a': DotDict(b=DotDict(c=1, e=3), d=2)} print(vars(x.a)) # {'b': DotDict(c=1, e=3), 'd': 2} About A simple Python library to make chained attributes possible. Resources Readme License GPL-3.0 license Activity Stars 23 stars Watchers 1 watching Forks 0 forks Report repository Releases 1 v0.0.1 Latest Aug 2, 2023 Packages 0 No packages published Languages * Python 100.0% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time.