# DotMap
`DotMap` is a dot-access `dict` subclass that
* has dynamic hierarchy creation
* can be initialized with keys
* easily initializes from :code:`dict`
* easily converts to :code:`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 :code:`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 :code:`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')
```
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.
`DotMap` is a dot-access `dict` subclass that
* has dynamic hierarchy creation
* can be initialized with keys
* easily initializes from :code:`dict`
* easily converts to :code:`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 :code:`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 :code:`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
# john DotMap(age=32, job='programmer')
# mary DotMap(age=24, job='designer')
# dave DotMap(age=55, job='manager')
```
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.
Release files for dotmap 1.2.27
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dotmap-1.2.27.tar.gz | 6.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dotmap-1.2.27-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.7 kB
Release files / dotmap-1.2.27.tar.gz
| Download URL | dotmap-1.2.27.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d73a3529f8640b5c1c865a2ba1cf6f1314171a7b7ffedd0d8c9eb565ab1ea4bb
|
|
BLAKE2b-256 checksum How to use checksums |
ad3e9068805c0e955a9205a0b833207a6b7e84bdb1fe6701984d4015e47f3be4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/2.7
|
Release files / dotmap-1.2.27-py3-none-any.whl
| Download URL | dotmap-1.2.27-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80e33f1dba1d010bca680d34d47badf509d5bd71bf9dac68b004af67032a13aa
|
|
BLAKE2b-256 checksum How to use checksums |
1c4ff7eb36ca55a8a315af373e6e2ce7c0677b6bbba56ecf1c6aa35a3ca51a0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.4
|