def dim_range_key(eldim):
    """
    Returns the key to look up a dimension range.
    """
    if isinstance(eldim, dim):
        dim_name = repr(eldim)
        if dim_name.startswith("'") and dim_name.endswith("'"):
            dim_name = dim_name[1:-1]
    else:
        dim_name = eldim.name
    return dim_name