Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vandersonmota/t_dict
Traversable Python Dictionaries
https://github.com/vandersonmota/t_dict
Last synced: 3 months ago
JSON representation
Traversable Python Dictionaries
- Host: GitHub
- URL: https://github.com/vandersonmota/t_dict
- Owner: vandersonmota
- License: bsd-3-clause
- Created: 2014-10-04T22:17:16.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2022-12-26T19:45:22.000Z (almost 2 years ago)
- Last Synced: 2024-06-25T12:44:27.755Z (5 months ago)
- Language: Python
- Size: 15.6 KB
- Stars: 61
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: HISTORY.rst
- Contributing: CONTRIBUTING.rst
- License: LICENSE
Awesome Lists containing this project
README
===============================
Traversable Dict
===============================.. image:: https://badge.fury.io/py/t_dict.png
:target: http://badge.fury.io/py/t_dict.. image:: https://travis-ci.org/vandersonmota/t_dict.png?branch=master
:target: https://travis-ci.org/vandersonmota/t_dict.. image:: https://pypip.in/d/t_dict/badge.png
:target: https://pypi.python.org/pypi/t_dictTraversing and Querying Dicts the easy way
* Free software: BSD license
Install
=======.. code-block:: console
pip install t_dict
Why?
--------Dealing with deep nested dicts can be a total pain. TDict aims to make less boring working with it, using jsonpointer syntax for that.
It stand on the shoulders of jsonpointer (https://pypi.python.org/pypi/jsonpointer), which implements the RFC - https://tools.ietf.org/html/rfc6901
Usage
--------.. code-block:: python
from t_dict.t_dict import TDict
td = TDict({'nested': { 'dict': 'here', 'other': {'spam': 'eggs'} }})
td.find('/nested/dict')
>> 'here'
td.find('/nested/notfound', 'defaultvalue')
>> 'defaultvalue'td.setin('/nested/dict', 'new')
td['nested']['dict'] == 'new'
>> True# converts dict to TDict
isinstance(td.find('/nested/other'), TDict)
>> True