Dotmap

1.3.30 · active · verified Sat Apr 11

Dotmap is a Python library that provides a dot-access dictionary, allowing dictionary keys to be accessed as object attributes (e.g., `m.key` instead of `m['key']`). It supports dynamic hierarchy creation, ordered iteration, and can be initialized from or converted back to standard Python dictionaries. The current stable version is 1.3.30, and it maintains an active release cadence with regular updates.

Warnings

Install

Imports

Quickstart

This example demonstrates how to initialize a DotMap, assign values using dot notation, dynamically create nested dictionaries and lists, and convert the DotMap instance back to a standard Python dictionary.

from dotmap import DotMap

# Initialize an empty DotMap
m = DotMap()

# Assign values using dot notation
m.name = 'Joe'

# Dynamically create nested structures
m.people.john.age = 32
m.people.john.job = 'coder'

# Append to lists (dynamically created)
m.list.append(1)
m.list.append(2)
m.list.append(3)

# Access values
print(f"Name: {m.name}")
print(f"John's Age: {m.people.john.age}")
print(f"List: {m.list}")

# Convert back to a standard dictionary
regular_dict = m.toDict()
print(f"Converted to dict: {regular_dict}")

view raw JSON →