dotmap-1.3.8
1.3.8
1.3.7
1.3.4
1.3.30
1.3.3
1.3.29
1.3.28
1.3.27
1.3.26
1.3.25
1.3.24
1.3.23
1.3.22
1.3.21
1.3.20
1.3.2
1.3.19
1.3.17
1.3.16
1.3.14
1.3.13
1.3.12
1.3.1
1.3.0
1.2.9
1.2.8
1.2.7
1.2.6
1.2.5
1.2.4
1.2.39
1.2.38
1.2.37
1.2.36
1.2.35
1.2.34
1.2.33
1.2.32
1.2.31
1.2.30
1.2.3
1.2.29
1.2.28
1.2.27
1.2.26
1.2.25
1.2.24
1.2.23
1.2.22
1.2.21
1.2.20
1.2.2
1.2.19
1.2.18
1.2.17
1.2.16
1.2.15
1.2.14
1.2.13
1.2.12
1.2.11
1.2.10
1.2.1
1.2.0
1.1.22
1.1.21
1.1.20
1.1.2
1.1.19
1.1.18
1.1.17
1.1.16
1.1.15
1.1.14
1.1.1
1.0.9
1.0.8
1.0.7
1.0.6
1.0.5
1.0.4
1.0.3
1.0.2
1.0.16
1.0.15
1.0.14
1.0.13
1.0.12
1.0.10
1.0.1
1.0
توضیحات
ordered, dynamically-expandable dot-access dictionary
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | dotmap-1.3.8 |
| نام | dotmap |
| نسخه کتابخانه | 1.3.8 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Chris Redford |
| ایمیل نویسنده | credford@gmail.com |
| آدرس صفحه اصلی | https://github.com/drgrib/dotmap |
| آدرس اینترنتی | https://pypi.org/project/dotmap/ |
| مجوز | MIT |
# DotMap
[](https://travis-ci.com/drgrib/dotmap)
[](https://www.paypal.com/donate?business=N2GLXLS5KBFBY&item_name=Chris+Redford¤cy_code=USD)
# Install
```
pip3 install dotmap
```
## Upgrade
Get updates for current installation
```
pip3 install --upgrade dotmap
```
# Features
`DotMap` is a dot-access `dict` subclass that
- has dynamic hierarchy creation (autovivification)
- can be initialized with keys
- easily initializes from `dict`
- easily converts to `dict`
- is ordered by insertion
The key feature is exactly what you want: dot-access
```python
from dotmap import DotMap
m = DotMap()
m.name = 'Joe'
print('Hello ' + m.name)
# Hello Joe
```
However, `DotMap` is a `dict` and you can treat it like a `dict` as needed
```python
print(m['name'])
# Joe
m.name += ' Smith'
m['name'] += ' Jr'
print(m.name)
# Joe Smith Jr
```
It also has fast, automatic hierarchy (which can be deactivated by initializing with `DotMap(_dynamic=False)`)
```python
m = DotMap()
m.people.steve.age = 31
```
And key initialization
```python
m = DotMap(a=1, b=2)
```
You can initialize it from `dict` and convert it to `dict`
```python
d = {'a':1, 'b':2}
m = DotMap(d)
print(m)
# DotMap(a=1, b=2)
print(m.toDict())
# {'a': 1, 'b': 2}
```
And it has iteration that is ordered by insertion
```python
m = DotMap()
m.people.john.age = 32
m.people.john.job = 'programmer'
m.people.mary.age = 24
m.people.mary.job = 'designer'
m.people.dave.age = 55
m.people.dave.job = 'manager'
for k, v in m.people.items():
print(k, v)
print
# john DotMap(age=32, job='programmer')
# mary DotMap(age=24, job='designer')
# dave DotMap(age=55, job='manager')
```
It also has automatic counter initialization
```python
m = DotMap()
for i in range(7):
m.counter += 1
print(m.counter)
# 7
```
And automatic addition initializations of any other type
```python
m = DotMap()
m.quote += 'lions'
m.quote += ' and tigers'
m.quote += ' and bears'
m.quote += ', oh my'
print(m.quote)
# lions and tigers and bears, oh my
```
There is also built-in `pprint` as `dict` or `json` for debugging a large `DotMap`
```python
m.pprint()
# {'people': {'dave': {'age': 55, 'job': 'manager'},
# 'john': {'age': 32, 'job': 'programmer'},
# 'mary': {'age': 24, 'job': 'designer'}}}
m.pprint(pformat='json')
# {
# "people": {
# "dave": {
# "age": 55,
# "job": "manager"
# },
# "john": {
# "age": 32,
# "job": "programmer"
# },
# "mary": {
# "age": 24,
# "job": "designer"
# }
# }
# }
```
And many other features involving dots and dictionaries that will be immediately intuitive when used.
نحوه نصب
نصب پکیج whl dotmap-1.3.8:
pip install dotmap-1.3.8.whl
نصب پکیج tar.gz dotmap-1.3.8:
pip install dotmap-1.3.8.tar.gz