dotwiz

raw JSON →
0.4.0 verified Sat May 09 auth: no python

DotWiz is a blazing fast dict subclass that enables accessing nested dictionary keys using dot notation. It wraps dictionaries and provides attribute-style access. Current version 0.4.0, maintained but not rapidly updated.

pip install dotwiz
error AttributeError: 'dict' object has no attribute 'subkey'
cause A nested dict was not converted to DotWiz because it was assigned after initialization.
fix
Use d.key = DotWiz({'subkey': value}) instead of d.key = {'subkey': value}
error TypeError: 'DotWiz' object is not callable
cause Trying to call dotwiz as a function instead of importing the class.
fix
Import the class: from dotwiz import DotWiz
error KeyError: 'key'
cause Trying to access a key that doesn't exist using bracket notation when attribute access would raise AttributeError.
fix
Check key exists with 'key' in d or use .get() method.
gotcha DotWiz does not convert nested dicts passed after creation. Only nested dicts at initialization are converted. Assigning a plain dict to a key after creation will not be automatically wrapped.
fix Manually wrap nested dicts: d.key = DotWiz({'subkey': 'value'})
gotcha DotWiz is not a full replacement for dict. Methods like .items(), .keys() work, but some dict methods (e.g., .copy()) return a plain dict, not a DotWiz.
fix If you need deep copy preserving DotWiz, use copy.deepcopy or wrap explicitly.
deprecated The module does not explicitly deprecate any features, but be aware that version 0.4.0 may have limited future updates.
fix Monitor the repository for any changes.

Basic usage: create a DotWiz instance and access nested keys with dot notation.

from dotwiz import DotWiz

# Create a DotWiz object
d = DotWiz({'name': 'John', 'info': {'age': 30, 'city': 'NYC'}})

# Access nested keys via dot notation
print(d.name)           # John
print(d.info.age)       # 30

# Assign values
d.info.city = 'Boston'
print(d)                # {'name': 'John', 'info': {'age': 30, 'city': 'Boston'}}