Skip to main content

Dot notation python dicationary

Project description

pydotmap

built with Python3

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", 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

How to use pydotmap decorator?

from pydotmap import dotmap

value = {"author": "atul"}


@dotmap
def check_decorator(in_value):
    return in_value.author

print(check_decorator(value))

Project details


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.8.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

pydotmap-0.0.8-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file pydotmap-0.0.8.tar.gz.

File metadata

  • Download URL: pydotmap-0.0.8.tar.gz
  • Upload date:
  • Size: 3.0 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

Hashes for pydotmap-0.0.8.tar.gz
Algorithm Hash digest
SHA256 b4e629565088dfa5cc86891f9d67b4c70e7534b6be04eb6bb2de06bd09320032
MD5 8fb27a6d043db8ff04985aff3173437b
BLAKE2b-256 5793ac38eea2c3a28d83d3217db263ae8d87e8e7626dda4771ecee0522fe40e4

See more details on using hashes here.

File details

Details for the file pydotmap-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: pydotmap-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 4.0 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

Hashes for pydotmap-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 11a188141fcf42bee33c3496879cbfdbf4717318e51a79c34f57d259742f0aa7
MD5 9815ced5409e91557727bf0f60583a9e
BLAKE2b-256 72545bfe9b7cd74acc6bcce84a8f825dec3e3831e6b5540c7bc72517d85d2d39

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page