schlichtanders.mydicts module

This module mainly collects dictionary subclasses, which are useful to partially modify a dict. But also a FrozenDict and a convenient update method for updating a dict with another, with options to specify overwriting/appending flags.

class schlichtanders.mydicts.ComposedDictsView(dict1, dict2, compose_type='stack', if_dict1_empty_iterate_over_dict2=False)[source]

Bases: _abcoll.Mapping

composes two dictionaries with the given compose method

COMPOSE_TYPES = ['stack', 'call', 'use_as_needed', 'defaultto', 'overwrite']
class schlichtanders.mydicts.DefaultDict(default_getitem=None, default_setitem=None, default_delitem=None, *args, **kwargs)[source]

Bases: dict

like collections.defaultdict, however default method is called with the accessed key

noexpand()[source]
class schlichtanders.mydicts.FrozenDict(*args, **kwargs)[source]

Bases: _abcoll.Mapping

This is a hashable wrapper around a dict interface

class schlichtanders.mydicts.HashableDict[source]

Bases: dict

class schlichtanders.mydicts.IdentityDict(*args, **kwargs)[source]

Bases: schlichtanders.mydicts.DefaultDict

almost like defaultdict, with the crucial difference that new keys are not added dynamically, but always regenerated

set_expand()[source]
class schlichtanders.mydicts.ModifyDict(base_dict, modify_getitem=<function <lambda>>)[source]

Bases: _abcoll.Mapping

class schlichtanders.mydicts.PassThroughDict(dict_like, *args, **kwargs)[source]

Bases: schlichtanders.mydicts.IdentityDict

postmap which passes everything through model if not further defined

schlichtanders.mydicts.recdefaultdict()[source]

this is an awesome little trick to have a dictionary with infinitely nested default dictionaries

schlichtanders.mydicts.update(dict1, dict2, overwrite=True, append=True)[source]

overwrites dict1 with dict2