Skip to content

Instantly share code, notes, and snippets.

View timdetering's full-sized avatar

Tim Detering timdetering

  • Seattle, WA
View GitHub Profile
@sherzberg
sherzberg / tupperware.py
Last active September 28, 2019 08:29 — forked from floer32/tupperware.py
from UserDict import IterableUserDict
import collections
def tupperware(mapping):
""" Convert mappings to 'tupperwares' recursively.
Lets you use dicts like they're JavaScript Object Literals (~=JSON)...
It recursively turns mappings (dictionaries) into namedtuples.
Thus, you can cheaply create an object whose attributes are accessible
@floer32
floer32 / tupperware.py
Last active September 26, 2022 12:13
recursively convert nested dicts to nested namedtuples, giving you something like immutable object literals
from UserDict import IterableUserDict
import collections
__author__ = 'github.com/hangtwenty'
def tupperware(mapping):
""" Convert mappings to 'tupperwares' recursively.