{"id":20595397,"url":"https://github.com/who8mylunch/orderednamespace","last_synced_at":"2026-04-27T05:01:26.841Z","repository":{"id":57449558,"uuid":"97342810","full_name":"Who8MyLunch/OrderedNamespace","owner":"Who8MyLunch","description":"An easy-to-use Python namespace class derived from OrderedDict, including tab-completion","archived":false,"fork":false,"pushed_at":"2019-12-29T21:22:34.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-03T20:54:59.424Z","etag":null,"topics":["dotdict","namespace","ordereddict","tab-completion"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/Who8MyLunch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-15T21:17:13.000Z","updated_at":"2019-12-29T21:22:36.000Z","dependencies_parsed_at":"2022-09-14T10:51:49.121Z","dependency_job_id":null,"html_url":"https://github.com/Who8MyLunch/OrderedNamespace","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Who8MyLunch/OrderedNamespace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Who8MyLunch%2FOrderedNamespace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Who8MyLunch%2FOrderedNamespace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Who8MyLunch%2FOrderedNamespace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Who8MyLunch%2FOrderedNamespace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Who8MyLunch","download_url":"https://codeload.github.com/Who8MyLunch/OrderedNamespace/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Who8MyLunch%2FOrderedNamespace/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32323215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["dotdict","namespace","ordereddict","tab-completion"],"created_at":"2024-11-16T08:12:53.550Z","updated_at":"2026-04-27T05:01:26.670Z","avatar_url":"https://github.com/Who8MyLunch.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OrderedNamespace\n\nDot-accessible attributes and namespaces are great ideas and this one is mine.\n\n## New Release - 2019.6.8\n\nThis latest update includes:\n- Jupyter/iPython pretty printing works even better than before.  Everything lines up and is easier to read at a glance.\n- Tab auto-completion now shows both class methods and data attribute.  Previously it only showed data attributes.\n- Full support for pickle serialization/deserialization.\n\n\n## Description\n\nWhat's the big deal?  Python dicts are just fine, but in the Jupyter/IPython interactive environment I hate having to deal with brackets and quotes when using tab-based auto-completion to get a quick glance at the contents of an object.\n\nOrderedNamespace has been especially designed to have a minimal number of things that bug me.  More specifically, I wanted my namespace implementation to support the following functionality:\n\n- Access data contents as dot-style attributes _or_ as dict keys\n- Predictable ordering of attributes/keys\n- Automatic support for tab-completion (especially within Jupyter Notebooks)\n- Nesting: auto-convert supplied dict data to OrderedNamespace instances\n- Nice pretty printing within Jupyter environment\n\nUltimately I decided to write a class from scratch and using an OrderedDict instance in place of the class' built-in `__dict__`.  This meant writing my own methods for `__setitem__`, `__getitem__`, `__getattr__` and `__setattr__`.  I also had to learn about automatic tab completion as used in Jupyter/IPython.  Overall it was more work than I originally anticipated, but it was all fun and I'm glade I did it.\n\nInstall this package with:\n\n```bash\npip install ordered-nanmespace\n```\n\nAnd then use it like this:\n\n```py\nimport ordered_namespace as ons\nimport numpy as np\n\ndata = ons.Struct()\n\ndata.X = [1, 2, 3]\n\ndata['Y'] = {'hello': 'I am not a robot',\n             'yikes': 75.4}\n\ndata.Z = np.arange(35).reshape(7,5)\n```\n\nNotice above that both dict key and attribute-style techniques were used to add new information to the namespace structure.  Printing out the data contents shows nicely-formatted pretty text:\n\n```py\n\u003e\u003e\u003e data\n\n[{X: [1, 2, 3],\n  Y: [{hello: 'I am not a robot', yikes: 75.4}],\n  Z: array([[ 0,  1,  2,  3,  4],\n            [ 5,  6,  7,  8,  9],\n            [10, 11, 12, 13, 14],\n            [15, 16, 17, 18, 19],\n            [20, 21, 22, 23, 24],\n            [25, 26, 27, 28, 29],\n            [30, 31, 32, 33, 34]])}]\n```\n\n\nInspiration for this class came from parts of the following projects:\n- https://docs.python.org/3.6/library/types.html#types.SimpleNamespace\n- https://github.com/srevenant/dictobj\n- https://github.com/pcattori/namespaces\n- https://github.com/pcattori/maps\n- https://stackoverflow.com/questions/27941581/replacing-default-dict-for-object-with-ordereddict\n- https://stackoverflow.com/questions/455059/using-an-ordered-dict-as-object-dictionary-in-python\n\nI learned about IPython's tab-completion at this link:\n- http://ipython.readthedocs.io/en/stable/config/integrating.html#tab-completion\n\nThe follwing were extremely helpful in sorting through IPython's rich-text display framework:\n- http://ipython.readthedocs.io/en/stable/config/integrating.html\n- https://github.com/ipython/ipython/blob/master/IPython/lib/pretty.py\n- https://docs.python.org/3/library/functions.html#dir\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwho8mylunch%2Forderednamespace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwho8mylunch%2Forderednamespace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwho8mylunch%2Forderednamespace/lists"}