https://github.com/croqaz/prop
Python library for getting a property from a nested object using a dot path
https://github.com/croqaz/prop
library python
Last synced: 12 months ago
JSON representation
Python library for getting a property from a nested object using a dot path
- Host: GitHub
- URL: https://github.com/croqaz/prop
- Owner: croqaz
- License: mit
- Created: 2019-11-21T21:50:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-28T22:44:12.000Z (almost 6 years ago)
- Last Synced: 2025-07-02T06:44:36.381Z (about 1 year ago)
- Topics: library, python
- Language: Python
- Homepage:
- Size: 40 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# prop · py
[![Pypi Version][pypi-image]][pypi-url]
[![Build Status][build-image]][build-url]
[![Code coverage][cover-image]][cover-url]
[![Python ver][python-image]][python-url]
A Python 🐍 library for getting a property from a nested object using a dot path.
## Usage
```py
import prop
data = {
'k1': 'v1',
'nested': {'x': 'y', 'int': 0, 'null': None},
'list': [[None, True, 9]]
}
prop.get(data, 'k1')
# v1
prop.get(data, 'nested.x')
# x
prop.get(data, 'list.0.1')
# True
prop.get(data, 'list.0.-1')
# 9
```
Limitations: For navigating dicts, only string keys are supported.
## Installation
```sh
$ pip install prop
```
## Similar libraries
* https://github.com/chrisinajar/py-dot-prop - (Python) Get a property from a dict or list
* https://github.com/sindresorhus/dot-prop - (Node.js) Get, set, or delete a property from a nested object using a dot path
* https://github.com/jonschlinkert/get-value - (Node.js) Use property paths (`a.b.c`) to get a nested value from an object
## License
[MIT](LICENSE) © Cristi Constantin.
[pypi-image]: https://img.shields.io/pypi/v/prop.svg
[pypi-url]: https://pypi.org/project/prop/
[build-image]: https://github.com/croqaz/prop/workflows/Python/badge.svg
[build-url]: https://github.com/croqaz/prop/actions
[cover-image]: https://codecov.io/gh/croqaz/prop/branch/master/graph/badge.svg
[cover-url]: https://codecov.io/gh/croqaz/prop
[python-image]: https://img.shields.io/badge/Python-3.6-blue.svg
[python-url]: https://python.org