Skip to content

Latest commit

 

History

History
27 lines (15 loc) · 760 Bytes

deeppath.rst

File metadata and controls

27 lines (15 loc) · 760 Bytes

Deep Path Strings

import pydash

A deep path string is used to access a nested data structure of arbitrary length. Each level is separated by a "." and can be used on both dictionaries and lists. If a "." is contained in one of the dictionary keys, then it can be escaped using "\". For accessing a dictionary key that is a number, it can be wrapped in brackets like "[1]".

Examples:

>>> data = {'a': {'b': {'c': [0, 0, {'d': [0, {1: 2}]}]}}} >>> pydash.get(data, 'a.b.c.2.d.1.[1]') 2

>>> data = {'a': {'b.c.d': 2}} >>> pydash.get(data, r'a.b.c.d') 2

Pydash's callback system supports the deep property style callback using deep path strings.