srn / selectn-py

Resolves deeply-nested dictionary properties via dot-notation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

selectn-py Build Status

Resolves deeply-nested dictionary properties via dot-notation

Inspired by the node library selectn

So you can do:

selectn('info.name.full', person)

instead of:

person and person['info'] and person['info']['name'] and person['info']['name']['full']

Install

$ pip install selectn-python

Usage

>>> from selectn import selectn
>>>
>>> dic = {'info': {'name': {'full': 'selectn'}}}
>>>
>>> selectn('info.name.full', dic)
'selectn'
>>> selectn('info.name.short', dic)
None

License

MIT © Søren Brokær

About

Resolves deeply-nested dictionary properties via dot-notation

License:MIT License


Languages

Language:Python 100.0%