Install & Compatibility
Where this runs
tested against v1.13 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
EasyDict
✓ from easydict import EasyDict
✗ from easydict import EasyDict as edict # Not 'wrong', but 'EasyDict' is the primary class name; 'edict' is a common alias.
The class is named `EasyDict`. `edict` is a popular alias used in many examples for brevity.
Demonstrates creating an EasyDict from a Python dictionary, accessing nested values with dot notation, modifying attributes, and showing that it retains dictionary-like behavior.
from easydict import EasyDict
# Create an EasyDict from a dictionary
data = EasyDict({
'settings': {
'debug': True,
'api_key': 'abc123xyz'
},
'users': [
{'id': 1, 'name': 'Alice'},
{'id': 2, 'name': 'Bob'}
]
})
# Access values using dot notation
print(f"Debug mode: {data.settings.debug}")
print(f"API Key: {data.settings.api_key}")
print(f"First user's name: {data.users[0].name}")
# Set new attributes or modify existing ones
data.settings.debug = False
data.new_feature = {'enabled': True}
print(f"New debug mode: {data.settings.debug}")
print(f"New feature enabled: {data.new_feature.enabled}")
# EasyDict still behaves like a dict
print(f"All keys: {list(data.keys())}")
Debug
Known issues
gotchaEasyDict is primarily designed for string keys when using dot notation. Attempting to access non-string keys (e.g., integers) as attributes will result in an AttributeError. You must use standard dictionary bracket notation for non-string keys.fixAccess non-string keys using `my_easydict[123]` instead of `my_easydict.123`.
affects: All versions
gotchaEasyDict recursively converts nested dictionaries and lists of dictionaries into EasyDict instances. This can sometimes lead to unexpected behavior if strict Python dict/list types are expected at certain levels, or if dealing with self-referencing dictionary structures, which can cause `RecursionError`.fixBe aware of the recursive conversion. If you need a plain dictionary, convert explicitly using `dict(my_easydict)` (note: this might not recursively convert nested EasyDicts back to plain dicts in older versions, requiring manual deep conversion). For `RecursionError` with class members, upgrade to >=1.11.
affects: <= 1.10 for `RecursionError` with class members (fixed in 1.11), but recursive conversion applies to all versions.
breakingIn versions prior to 1.12, tuples assigned as values within an EasyDict could be incorrectly converted to lists. This could alter data structures unintentionally.fixUpgrade to EasyDict version 1.12 or newer to ensure tuples are preserved as tuples.
affects: < 1.12
breakingThe `.pop()` and `.update()` methods had incorrect behavior in versions prior to 1.9, particularly when dealing with EasyDict instances.fixUpgrade to EasyDict version 1.9 or newer to ensure correct functionality of `.pop()` and `.update()`.
affects: < 1.9
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'easydict'
The easydict library is not installed in the Python environment where the code is being executed.
AttributeError: 'EasyDict' object has no attribute 'some_key'
You are attempting to access a non-existent key as an attribute on an EasyDict object.
fixEnsure the key 'some_key' actually exists in your EasyDict object. You can check its existence using `'some_key' in your_easydict` or safely retrieve its value using `your_easydict.get('some_key', default_value)` to avoid the error. AttributeError: 'EasyDict' object has no attribute 'iteritems'
This error occurs when running Python 2 code in a Python 3 environment. The `iteritems()` method for iterating over dictionary items was removed in Python 3 and replaced by `items()`.
fixReplace `.iteritems()` with `.items()` in your code.
KeyError: 'some_key'
When treating an EasyDict instance like a regular dictionary, you attempted to access a key using bracket notation (`my_easydict['some_key']`) that does not exist within the dictionary.
fixVerify that 'some_key' exists before accessing it, or use the `.get()` method to provide a default value if the key is not found, e.g., `my_easydict.get('some_key', None)`. Upgrade
Version history
1.13latest on PyPI · released Mar 4, 2024
Audit
Dependencies
No dependency data recorded yet.