def build_mapping(iterable, stepper=None):
    """A generator for mapping the iterable to stepped values.

      iterable - the keys for the mapping.  It is also used by the
            stepper to generate the mapped values.
      stepper - the callable returning an iterator of the mapped
            values.  

    If a mapping is passed for the iterable, it is returned directly
    and the stepper is not used.  Otherwise, the stepper will be passed
    the iterable to generate the mapping.

    The stepper function should not change the iterable.  Neither
    should it produce keys other than those from the iterable.  A
    default stepper from step_count_factory() will be used if one is
    not passed.

    """

    try:
        for key in iterable:
            yield key, iterable[key]
    except TypeError:
        if stepper is None:
            stepper = step_index_factory(step=1)
        for key, value in stepper(iterable):
            yield key, value
A generator for mapping the iterable to stepped values.

      iterable - the keys for the mapping.  It is also used by the
            stepper to generate the mapped values.
      stepper - the callable returning an iterator of the mapped
            values.  

    If a mapping is passed for the iterable, it is returned directly
    and the stepper is not used.  Otherwise, the stepper will be passed
    the iterable to generate the mapping.

    The stepper function should not change the iterable.  Neither
    should it produce keys other than those from the iterable.  A
    default stepper from step_count_factory() will be used if one is
    not passed.

    
recipes/Python/577755_Simple_but_Powerful_Grouped_Constants__Step/recipe-577755.py