def to_from_idx(iterable, start_idx=0):
    """Return mappings of items in iterable to and from their index.

    >>> char2idx, idx2char = to_from_idx("abcdefg")
    >>> char2idx
    {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6}
    >>> idx2char
    {0: 'a', 1: 'b', 2: 'c', 3: 'd', 4: 'e', 5: 'f', 6: 'g'}
    """
    return map(dict, zip(*(
        ((item, i), (i, item))
        for i, item in enumerate(iterable, start=start_idx))))