Registry / serialization / python-benedict

python-benedict

JSON →
library0.38.0pypypi✓ verified 25d ago

python-benedict is a `dict` subclass that enhances the standard Python dictionary with powerful features like keylist, keypath, and keyattr support. It provides normalized I/O operations for various data formats (including base64, csv, ini, json, pickle, plist, query-string, toml, xls, xml, yaml) and numerous utility methods. It is currently active, with its latest version being 0.35.0, and maintains a regular release cadence.

pip install python-benedict
INSTALL
IMPORT
SIG · PYTHON-BENEDICT
P
python-benedict
serializationpythonv0.38.0
Install
6.0s avg
Import
1286ms
Disk
25MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.38.0 · 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
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 1.060s · 19.3MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 6.0s · import 0.998s · 20MB
25MB installed
● package 25MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

benedict
from benedict import benedict

This example demonstrates creating a `benedict` instance, accessing and setting values using both keypath (dot notation) and keylist (list of keys), and serializing the dictionary to a JSON string.

from benedict import benedict # Create a benedict instance from a dictionary data = { "user": { "profile": { "name": "Alice", "email": "alice@example.com" }, "id": 123 }, "settings": { "theme": "dark" } } d = benedict(data) # Access values using keypath (dot notation) print(f"User Name: {d['user.profile.name']}") # Set values using keypath d['user.profile.age'] = 30 print(f"User Age: {d.get('user.profile.age')}") # Access using keylist (list of keys) print(f"User ID: {d[['user', 'id']]}") # Output to JSON string json_output = d.to_json(indent=2) print("\nJSON Output:") print(json_output)
benedict --version
Debug
Known issues
breakingVersion 0.34.0 dropped official support for Python 3.8 and 3.9. Users on these versions should remain on an earlier `python-benedict` release or upgrade their Python interpreter.
fix
Upgrade Python to 3.10 or newer, or pin `python-benedict<0.34.0`.
affects: >=0.34.0
breakingIn version 0.34.0, the `keylist` feature was fixed to work only with actual lists, addressing previous backward-compatibility issues with standard `dict` behavior. If you previously relied on non-list iterables for keylist operations, your code may break.
fix
Ensure that arguments passed for keylist access are strictly `list` types.
affects: >=0.34.0
gotchaWhen casting an existing `dict` to a `benedict` instance, if the original dictionary's keys contain the default keypath separator ('.'), a `ValueError` may be raised.
fix
Either choose a custom keypath separator by passing `keypath_separator='_'` (or another suitable character) to the `benedict` constructor, or disable keypath functionality with `keypath=False` if not needed. Alternatively, sanitize keys in the original dictionary.
affects: <all>
gotchaAs of version 0.32.1, the `items()` and `values()` methods return `benedict` instances (or `list` of `benedict` instances for values) rather than standard `dict_items` or `dict_values` objects. This might affect type checks or expected iteration behavior.
fix
Adjust code to expect `benedict` instances from `items()` and `values()`, or explicitly cast results to `dict` if standard `dict` behavior is strictly required.
affects: >=0.32.1
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'benedict'
The 'python-benedict' library is not installed in the current Python environment.
fix
pip install python-benedict
KeyError: 'path.to.missing.key'
Attempting to access a non-existent nested key using keypath notation when 'raise_key_error_on_missing' is enabled (default behavior).
fix
Use the `get()` method with a default value (e.g., `data.get('path.to.missing.key', None)`) or check for key existence with the `in` operator (e.g., `if 'path.to.missing.key' in data:`).
ImportError: Missing optional dependency 'lxml'. Use pip or conda to install lxml.
The 'lxml' library, which is an optional dependency required for XML processing (e.g., with `from_xml()`), is not installed.
fix
Install the required dependency using pip: `pip install lxml` or install 'python-benedict' with its xml extra: `pip install python-benedict[xml]`.
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
The input string provided to `benedict.from_json()` (or similar `from_` methods like `from_yaml()`) is not a valid JSON document or is malformed.
fix
Ensure the input string is a well-formed document according to its respective format (e.g., JSON, YAML) before passing it to the `benedict.from_json()` method.
Upgrade
Version history
0.38.0latest on PyPI · released Jul 7, 2026
Audit
Dependencies
htmloptionalEnables `from_html` method and related HTML I/O operations.
tomloptionalEnables TOML I/O operations (`from_toml`, `to_toml`).
xlsoptionalEnables XLS I/O operations (`from_xls`).
xmloptionalEnables XML I/O operations (`from_xml`, `to_xml`).
yamloptionalEnables YAML I/O operations (`from_yaml`, `to_yaml`).
parseoptionalProvides additional parsing utilities.
s3optionalEnables S3 backend support for I/O operations.
Agent activity
17 hits · last 30 days
node
6
Resources
python-benedict — pip install python-benedict · libregistry