Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

ordered, dynamically-expandable dot-access dictionary

Project Description

DotMap is a dot-access dict subclass that

  • has dynamic child creation
  • 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

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

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))

m = DotMap()
m.people.steve.age = 31

And key initialization

m = DotMap(a=1, b=2)

You can initialize it from dict and convert it to dict

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

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 for debugging a large DotMap

m.pprint()
# {'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 History

Release History

This version
History Node

1.2.17

History Node

1.2.16

History Node

1.2.15

History Node

1.2.14

History Node

1.2.13

History Node

1.2.12

History Node

1.2.11

History Node

1.2.10

History Node

1.2.9

History Node

1.2.8

History Node

1.2.7

History Node

1.2.6

History Node

1.2.5

History Node

1.2.4

History Node

1.2.3

History Node

1.2.2

History Node

1.2.1

History Node

1.2.0

History Node

1.1.22

History Node

1.1.21

History Node

1.1.20

History Node

1.1.19

History Node

1.1.18

History Node

1.1.17

History Node

1.1.16

History Node

1.1.15

History Node

1.1.14

History Node

1.1.2

History Node

1.1.1

History Node

1.0.16

History Node

1.0.15

History Node

1.0.14

History Node

1.0.13

History Node

1.0.10

History Node

1.0.9

History Node

1.0.8

History Node

1.0.7

History Node

1.0.6

History Node

1.0.5

History Node

1.0.4

History Node

1.0.3

History Node

1.0.2

History Node

1.0.1

History Node

1.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
dotmap-1.2.17.tar.gz (5.5 kB) Copy SHA256 Checksum SHA256 Source Mar 17, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting