pydotmap
This package is just a wrapper to python standard library dict and OrderedDict from pythoncollections library with support of pickling and unpickling. It will also make you able to use decorator that will save your time to convert dict definition param to pydotmap. It will allow you to use python dict or dictionary as dot notation just like javascript object.
How to initialize?
author = DotMap(name="Atul", surname="Singh")
Or
from pydotmap import DotMap
author = DotMap()
author.name = "Atul"
author.surname = "Singh"
Or
from pydotmap import DotMap
author = DotMap({"name": "Atul", "surname": "Singh"})
print(author.name, author.surname)
How to use?
from pydotmap import DotMap
from pydotmap import OrderedDotMap
author = DotMap(name="Atul", surname="Singh", addr=["country": "India"])
print(author.name)
print(author.surname)
del author.surname
print(author.surname)
print(author.get("surname", "singh")) # you can use your default value same as dict
print(author.addr[0].country)
# Ordered Map - This will maintain the order of your dictionary
author = OrderedDotMap(name="atul", surname="singh", addr=[{"country": "India"}])
print(author)
You can pickle it also. How?
from pydotmap import DotMap
import pickle
author = DotMap(name="Atul")
print(pickle.dumps(author))
OUTPUT
b'\x80\x04\x952\x00\x00\x00\x00\x00\x00\x00\x8c\x0epydotmap.pymap\x94\x8c\x06DotMap\x94\x93\x94)\x81\x94\x8c\x04name\x94\x8c\x04Atul\x94sh\x03b.'
you can use OrderedDotMap same way as DotMap to create pickle dump
How to use pydotmap decorator?
from pydotmap import dotmap, ordered_dotmap
value = {"author": "atul"}
@dotmap
def check_dotmap_decorator(in_value):
return in_value.author
print(check_dotmap_decorator(value))
@ordered_dotmap
def check_orderedmap_decorator(in_value):
return in_value.author
print(check_orderedmap_decorator(value))
Metadata
Release files for pydotmap 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pydotmap-0.1.3.tar.gz | 2.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydotmap-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.0 kB
Release files / pydotmap-0.1.3.tar.gz
| Download URL | pydotmap-0.1.3.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8180d2c9adb6cc630d196720b76f0fe9bc275795b8ea2f6fdab856de8a9264ec
|
|
BLAKE2b-256 checksum How to use checksums |
0cf195cf1eb7ab466e2530b57af415f89cf3e5b4599beee32f112ec336901272
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.6.12
|
Release files / pydotmap-0.1.3-py3-none-any.whl
| Download URL | pydotmap-0.1.3-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba7187e76e5e8723344de5a2e643e8ad44724fdc4f387284b3ddfe8fd03157dd
|
|
BLAKE2b-256 checksum How to use checksums |
011d9bafb4dc7b7538f8b864e4a82fcb1597d5c9bd65ce53baa75348797f985a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.6.12
|