class D(dict):
def __missing__(self, key):
self[key] = D()
return self[key]
d = D()
d['a']['b']['c'] = 3
More Related Contents:
- How to map dict into another dict Python
- Create a list of names whose height is higher than 160 – Explanation on nested dicts cycling [closed]
- Determine the type of an object?
- Getting key with maximum value in dictionary?
- Is there any pythonic way to combine two dicts (adding values for keys that appear in both)?
- multiprocessing: How do I share a dict among multiple processes?
- I’m getting Key error in python
- Is there a decorator to simply cache function return values?
- Getting a list of values from a list of dicts
- Merge and sum of two dictionaries
- Accessing elements of Python dictionary by index
- Intersecting two dictionaries
- How can I make a dictionary from separate lists of keys and values?
- Python creating a dictionary of lists
- Python dictionary keys. “In” complexity
- Removing Duplicates From Dictionary
- How to convert list of key-value tuples into dictionary?
- Can I patch a Python decorator before it wraps a function?
- Combining Dictionaries Of Lists In Python
- Set attributes from dictionary in python
- Float values as dictionary key
- Python 3 dictionary with known keys typing
- Check if a given key already exists in a dictionary and increment it
- How can I use a dictionary to do multiple search-and-replace operations? [duplicate]
- How to get count dict of items but maintain the order in which they appear?
- Only add to a dict if a condition is met
- Using python decorator with or without parentheses
- Getting the difference (delta) between two lists of dictionaries
- Python: iterating over list vs over dict items efficiency
- Why does dict(k=4, z=2).update(dict(l=1)) return None in Python? [duplicate]