skip to navigation
skip to content

dictsearch 1.2

A tool for iterating dictionaries as trees and printing all leaf nodes at some path

Latest Version: 3.1.0

Usage

Takes a dict, and a path delimited with slashes like A/B/C/D, and returns a list of all leaves at all trajectories dict[A][B][C][D]

If the path is an empty string, returns the original dict

Each non-leaf node can be either a dictionary or list of objects including dictionaries.

Each leaf node can be an arbitrary object.

Non-leaf inner nodes that are not dictionaries are ignored.

Motivation

Jsons sometimes have many levels and are a pain to parse.

This package was motivated by the pain in iterating dicts I received from calling simplejson on objects returned from various Twitter API calls. The API objects I had to parse had quadruple level nested dictionaries, and when I was playing around with the data, I wanted to be able to query different levels to see if the data was interesting.
Then I found out nothing in the Python language natively supports querying nested dicts when they may or may not exist: http://stackoverflow.com/questions/26979046/python-check-multi-level-dict-key-existence
 
File Type Py Version Uploaded on Size
dictsearch-1.2.tar.gz (md5) Source 2015-01-24 1KB