Skip to main content
Version: 0.6

special_dicts

superduper.misc.special_dicts

Source code

dict_to_ascii_table​

dict_to_ascii_table(d)
ParameterDescription
dConvert a dictionary to a table.

Return a single string that represents an ASCII table.

Each key/value in the dict is a column. Columns are centered and padded based on the widest string needed (key or value).

diff​

diff(r1,
r2)
ParameterDescription
r1Dict
r2Dict

Get the difference between two dictionaries.

_diff({'a': 1, 'b': 2}, {'a': 2, 'b': 2})
# {'a': (1, 2)}
_diff({'a': {'c': 3}, 'b': 2}, {'a': 2, 'b': 2})
# {'a': ({'c': 3}, 2)}

recursive_find​

recursive_find(data,
check_function: Callable)
ParameterDescription
dataDict, List, Tuple, Set
check_functionCallable

Recursively find items in data that satisfy a check function.

recursive_update​

recursive_update(data,
replace_function: Callable)
ParameterDescription
dataDict, List, Tuple, Set
replace_functionCallable

Recursively update data with a replace function.

DeepKeyedDict​

DeepKeyedDict(self,
/,
*args,
**kwargs)
ParameterDescription
args*args for dict
kwargs**kwargs for dict

Dictionary object mirroring how MongoDB handles fields.

IndexableDict​

IndexableDict(self,
ordered_dict)
ParameterDescription
ordered_dictOrderedDict

IndexableDict.

# Example:
# -------
d = IndexableDict({'a': 1, 'b': 2})
d[0]
# 1
d[1]
# 2