More Dots! Dot-access to Python dicts like Javascript
Maintained. Last release 2 weeks ago, commits in 8 of the last 26 weeks. Weaker on contributor spread and security practices.
More Dots! Dot-access to Python dicts like Javascript
Maintained. Last release 2 weeks ago, commits in 8 of the last 26 weeks. Weaker on contributor spread and security practices.
pip install mo-dotsBox your JSON-like data in a Data object to get null-safe dot access. This library is a replacement for dict that is more consistent and easier to use.
See full documentation for all the features of
mo-dots
See change log to read about major changes
Define Data using named parameters, just like you would a dict
>>> from mo_dots import Data
>>> Data(b=42, c="hello world")
Data({'b': 42, 'c': 'hello world'})
You can also box an existing dicts so they can be used like Data
>>> from mo_dots import to_data
>>> to_data({'b': 42, 'c': 'hello world'})
Data({'b': 42, 'c': 'hello world'})
Access properties with attribute dots: a.b == a["b"]. You have probably seen this before.
Access properties by dot-delimited path.
>>> a = to_data({"b": {"c": 42}})
>>> a["b.c"] == 42
True
If a property does not exist then return Null rather than raising an error.
>>> a = Data()
>>> a.b == Null
True
>>> a.b.c == Null
True
>>> a[None] == Null
True
No need to make intermediate dicts
>>> a = Data()
>>> a["b.c"] = 42 # same as a.b.c = 42
a == {"b": {"c": 42}}
Use += to add to a property; default zero (0)
>>> a = Data()
a == {}
>>> a.b.c += 1
a == {"b": {"c": 1}}
>>> a.b.c += 42
a == {"b": {"c": 43}}
Use += with a list ([]) to append to a list; default empty list ([])
>>> a = Data()
a == {}
>>> a.b.c += [1]
a == {"b": {"c": [1]}}
>>> a.b.c += [42]
a == {"b": {"c": [1, 42]}}
Use mo-json: value2json converts Data, FlatList and many more structures to JSON, and json2value answers Data.
from mo_dots import to_data
from mo_json import value2json
result = value2json(to_data({"a": ["b", 1]}))
Where mo-json is not a dependency, the standard library works with default=from_data, which converts the data structures in this module into Python primitives of the same:
result = json.dumps(s, default=from_data)
This repo is a Claude Code plugin marketplace. Its mo-dots skill teaches an agent to write code with this library:
/plugin marketplace add klahnakoski/mo-dots
/plugin install mo-dots@mo-dots
Without the plugin, add this line to your project's CLAUDE.md:
Code using mo-dots follows https://github.com/klahnakoski/mo-dots/blob/dev/plugins/mo-dots/skills/mo-dots/SKILL.md
This library is the basis for a data transformation algebra: We want a succinct way of transforming data in Python. We want operations on data to result in yet more data. We do not want data operations to raise exceptions. This library also solves Python's lack of consistency (lack of closure) under the dot (.) and slice [::] operators when operating on data objects.
Use instead of mo-dots: tools that do the same job, closest first.
Compare with dotty-dict →Compare with easydict →Compare with dotmap →Compare all 4 →
Dictionary wrapper for quick access to deeply nested keys.
Recent release
last release 14 days ago
Commit activity
8/26 weeks with commits
Release cadence
6 releases in 12 months
Issues & PRs handled
no data
Contributor spread
1 authors in last 100 commits
OpenSSF Scorecard
3.8/10
Access dict values as attributes (works recursively).
ordered, dynamically-expandable dot-access dictionary
A dot-accessible dictionary (a la JavaScript objects)
A dict with dot-accessible attributes, IDE auto-completion and type conversion driven by annotations.
A set of Python dictionary objects where keys can be accessed as instance attributes.