Put a value into nested dicts by the order of the given keys tuple.

    Any missing intermediate dicts are created.

    Parameters
    ----------
    dict_obj : dict
        The outer-most dict to put in.
    key_tuple : tuple
        The keys to use for putting, in order.
    value : object
        The value to put.

    Example
    -------
    >>> dict_obj = {'a': {'h': 3}}
    >>> put_nested_val(dict_obj, ('a', 'b'), 7)
    >>> dict_obj['a']['b']
    7
    >>> put_nested_val(dict_obj, ('a', 'b'), 12)
    >>> dict_obj['a']['b']
    12
    >>> put_nested_val(dict_obj, ('a', 'g', 'z'), 14)
    >>> dict_obj['a']['g']['z']
    14
    >>> put_nested_val(dict_obj, ['base'], 88)
    >>> dict_obj['base']
    88

def put_nested_val(dict_obj, key_tuple, value):
    """Put a value into nested dicts by the order of the given keys tuple.

    Any missing intermediate dicts are created.

    Parameters
    ----------
    dict_obj : dict
        The outer-most dict to put in.
    key_tuple : tuple
        The keys to use for putting, in order.
    value : object
        The value to put.

    Example
    -------
    >>> dict_obj = {'a': {'h': 3}}
    >>> put_nested_val(dict_obj, ('a', 'b'), 7)
    >>> dict_obj['a']['b']
    7
    >>> put_nested_val(dict_obj, ('a', 'b'), 12)
    >>> dict_obj['a']['b']
    12
    >>> put_nested_val(dict_obj, ('a', 'g', 'z'), 14)
    >>> dict_obj['a']['g']['z']
    14
    >>> put_nested_val(dict_obj, ['base'], 88)
    >>> dict_obj['base']
    88
    """
    current_dict = dict_obj
    for key in key_tuple[:-1]:
        try:
            current_dict = current_dict[key]
        except KeyError:
            current_dict[key] = {}
            current_dict = current_dict[key]
    current_dict[key_tuple[-1]] = value