mo-dots-9.606.24115
9.606.24115
9.605.24115
9.603.24115
9.602.24115
9.601.24115
9.600.24114
9.596.24113
9.595.24112
9.594.24112
9.593.24112
9.592.24112
9.584.24095
9.582.24095
9.578.24081
9.574.24078
9.570.24076
9.565.24076
9.564.24076
9.563.24076
9.562.24075
9.549.24062
9.547.24058
9.543.24046
9.541.24038
9.531.24035
9.530.24035
9.527.24034
9.520.24032
9.508.24028
9.502.24024
9.499.24023
9.491.24021
9.490.24021
9.476.24007
9.474.24004
9.455.23316
9.450.23304
9.440.23265
9.430.23234
9.428.23214
9.417.23168
9.408.23161
9.401.23144
9.376.23121
9.368.23092
9.365.23080
9.356.23062
9.341.23006
9.340.23006
9.339.23006
8.519.24031
8.518.24031
8.517.24030
8.516.24030
8.515.24030
8.514.24030
8.513.24030
8.509.24030
10.685.25166
10.678.25061
10.677.25059
10.672.25036
10.671.25036
10.659.25005
10.647.24166
10.645.24152
10.632.24139
10.630.24136
10.627.24136
10.623.24125
10.622.24125
10.621.24125
10.615.24125
10.614.24125
10.613.24121
10.612.24121
10.611.24120
9.606.24115
9.605.24115
9.603.24115
9.602.24115
9.601.24115
9.600.24114
9.596.24113
9.595.24112
9.594.24112
9.593.24112
9.592.24112
9.584.24095
9.582.24095
9.578.24081
9.574.24078
9.570.24076
9.565.24076
9.564.24076
9.563.24076
9.562.24075
9.549.24062
9.547.24058
9.543.24046
9.541.24038
9.531.24035
9.530.24035
9.331.23005
9.300.22349
9.279.22339
9.278.22339
9.266.22338
9.251.22317
9.249.22317
9.238.22316
9.230.22310
9.213.22307
9.207.22283
9.189.22201
9.173.22126
9.169.22121
9.168.22121
9.163.22119
9.147.22086
9.134.22048
9.132.22039
9.128.22026
9.113.22021
9.110.22021
9.107.22008
9.101.22008
8.4.21326
8.20.21357
7.4.21313
6.2.21303
5.8.21181
5.57.21262
5.22.21182
5.17.21182
4.41.21142
4.22.21108
4.2.20340
4.19.21059
3.93.20259
3.92.20258
3.91.20246
3.85.20198
3.84.20198
3.8.19316
3.78.20194
3.77.20190
3.74.20189
3.73.20189
3.72.20189
3.63.20108
3.62.20101
3.53.20059
3.52.20059
3.51.20059
3.47.20042
3.46.20032
3.41.20031
3.33.20028
3.32.20028
3.22.19344
3.2.19316
3.19.19344
3.149.20327
3.141.20326
3.140.20326
3.14.19317
3.135.20303
2.9.18212
2.8.18211
2.7.18148
2.53.19239
2.5.18148
2.46.19127
2.45.19103
2.43.19055
2.4.18148
2.37.19026
2.36.19026
2.32.19026
2.31.19025
2.30.19025
2.29.19025
2.27.19008
2.21.19007
2.20.18318
2.18.18240
2.17.18212
10.685.25166
10.678.25061
10.677.25059
10.672.25036
10.671.25036
10.659.25005
10.647.24166
10.645.24152
10.632.24139
10.630.24136
10.627.24136
10.623.24125
10.622.24125
10.621.24125
10.615.24125
10.614.24125
10.613.24121
10.612.24121
10.611.24120
1.7.18029
1.7.18025
1.7.18013
1.7.17339
1.6.17319
توضیحات
More Dots! Dot-access to Python dicts like Javascript
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | mo-dots-9.606.24115 |
| نام | mo-dots |
| نسخه کتابخانه | 9.606.24115 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Kyle Lahnakoski |
| ایمیل نویسنده | kyle@lahnakoski.com |
| آدرس صفحه اصلی | https://github.com/klahnakoski/mo-dots |
| آدرس اینترنتی | https://pypi.org/project/mo-dots/ |
| مجوز | MPL 2.0 |
# More Dots!
[](https://pypi.org/project/mo-dots/)
[](https://github.com/klahnakoski/mo-dots/actions/workflows/build.yml)
[](https://coveralls.io/github/klahnakoski/mo-dots?branch=dev)
[](https://pepy.tech/project/mo-dots)
## Overview
Box your JSON-like data in a `Data` object to get null-safe dot access. This library is a replacement for `dict` that is more consistent and easier to use.
> See [full documentation](https://github.com/klahnakoski/mo-dots/tree/dev/docs) for all the features of `mo-dots`
> See [change log](https://github.com/klahnakoski/mo-dots/tree/dev/docs/CHANGELOG.md) to read about major changes
### Create instances
Define `Data` using named parameters, just like you would a `dict`
>>> from mo_dots import Data
>>> Data(b=42, c="hello world")
Data({'b': 42, 'c': 'hello world'})
You can also box an existing `dict`s so they can be used like `Data`
>>> from mo_dots import to_data
>>> to_data({'b': 42, 'c': 'hello world'})
Data({'b': 42, 'c': 'hello world'})
### Dot Access
Access properties with attribute dots: `a.b == a["b"]`. You have probably seen this before.
### Path Access
Access properties by dot-delimited path.
>>> a = to_data({"b": {"c": 42}})
>>> a["b.c"] == 42
True
### Null-Safe Access
If a property does not exist then return `Null` rather than raising an error.
>>> a = Data()
>>> a.b == Null
True
>>> a.b.c == Null
True
>>> a[None] == Null
True
### Path assignment
No need to make intermediate `dicts`
>>> a = Data()
>>> a["b.c"] = 42 # same as a.b.c = 42
a == {"b": {"c": 42}}
### Path accumulation
Use `+=` to add to a property; default zero (`0`)
>>> a = Data()
a == {}
>>> a.b.c += 1
a == {"b": {"c": 1}}
>>> a.b.c += 42
a == {"b": {"c": 43}}
Use `+=` with a list (`[]`) to append to a list; default empty list (`[]`)
>>> a = Data()
a == {}
>>> a.b.c += [1]
a == {"b": {"c": [1]}}
>>> a.b.c += [42]
a == {"b": {"c": [1, 42]}}
## Serializing to JSON
The standard Python JSON library does not recognize `Data` as serializable. You may overcome this by providing `default=from_data`; which converts the data structures in this module into Python primitives of the same.
from mo_dots import from_data, to_data
s = to_data({"a": ["b", 1]})
result = json.dumps(s, default=from_data)
Alternatively, you may consider [mo-json](https://pypi.org/project/mo-json/) which has a function `value2json` that converts a larger number of data structures into JSON.
## Summary
This library is the basis for a data transformation algebra: We want a succinct way of transforming data in Python. We want operations on data to result in yet more data. We do not want data operations to raise exceptions. This library also solves Python's lack of consistency (lack of closure) under the dot (`.`) and slice `[::]` operators when operating on data objects.
[Full documentation](https://github.com/klahnakoski/mo-dots/tree/dev/docs)
نیازمندی
| مقدار | نام |
|---|---|
| - | mo-future==7.685.25166 |
| - | mo-imports==7.685.25166 |
| xtr | mo-logs>=8.672.25036; |
| xtr | mo-json>=6.672.25036; |
| xtr | mo-threads>=6.672.25036; |
| xtr | mo-testing>=8.674.25037; |
| xtr | pyLibrary>=3.264.22338; |
| xtr | mo-math>=7.672.25036; |
| xtr | mo-times>=5.672.25036; |
| xtr | jx-elasticsearch>=3.99.20292; |
| xtr | beautifulsoup4>=4.13.3; |
نحوه نصب
نصب پکیج whl mo-dots-9.606.24115:
pip install mo-dots-9.606.24115.whl
نصب پکیج tar.gz mo-dots-9.606.24115:
pip install mo-dots-9.606.24115.tar.gz