Dot notation python dicationary
Project description
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 allow you to use python dict or dictionary as dot notation just like javascript object.
How to initialize?
author = DotMap(name="Atul", sirname="Singh")
Or
from pydotmap import DotMap
author = DotMap()
author.name = "Atul"
author.sirname = "Singh"
How to use?
from pydotmap import DotMap
from pydotmap import OrderedDotMap
author = DotMap(name="Atul", sirname="Singh", addr=["country": "India"])
print(author.name)
print(author.sirname)
del author.sirname
print(author.sirname)
print(author.get("sirname", "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", sirname="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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pydotmap-0.0.7.tar.gz
(2.7 kB
view details)
Built Distribution
File details
Details for the file pydotmap-0.0.7.tar.gz
.
File metadata
- Download URL: pydotmap-0.0.7.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.23.0 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42abe0e1934801ae0426a628dad6f3d0dbfe4ef79e32c2322dbf1ac178fc9dd7 |
|
MD5 | b89cc2128ed7cd6680735c497792fe20 |
|
BLAKE2b-256 | 91a340220ea896b59edd7145d593d30f1de49775eea14b801be8c565feb37602 |
File details
Details for the file pydotmap-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: pydotmap-0.0.7-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.23.0 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21445a6b898ab549459e319100da46a1dc8d599fed8d925da45f785207d8f937 |
|
MD5 | dc7d9f6a812cbb0a3cb47b02da85d965 |
|
BLAKE2b-256 | 9297975a229b4c4dbe2b10ac69e6d2c566124e0bf16e7c6a13c18205cdc20b96 |