https://github.com/srn/selectn-py
Resolves deeply-nested dictionary properties via dot-notation
https://github.com/srn/selectn-py
Last synced: about 1 year ago
JSON representation
Resolves deeply-nested dictionary properties via dot-notation
- Host: GitHub
- URL: https://github.com/srn/selectn-py
- Owner: srn
- License: mit
- Created: 2015-11-25T07:21:58.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-25T09:07:24.000Z (over 10 years ago)
- Last Synced: 2025-04-13T03:12:58.646Z (about 1 year ago)
- Language: Python
- Homepage:
- Size: 7.81 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# selectn-py [](https://travis-ci.org/srn/selectn-py)
> Resolves deeply-nested dictionary properties via dot-notation
Inspired by the node library [selectn](https://github.com/wilmoore/selectn.js)
So you can do:
```python
selectn('info.name.full', person)
```
instead of:
```python
person and person['info'] and person['info']['name'] and person['info']['name']['full']
```
## Install
```sh
$ pip install selectn-python
```
## Usage
```python
>>> 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](http://srn.io)