def wrapped_list(list, which):
    """
    Selects an element from a list, wrapping in either direction.
    """
    if which < 0:
        ix = len(list) + (which % len(list))
    else:
        ix = which % len(list)

    return list[ix]