'Convert from indexes in the unspaced list to positions in the spaced one'

def _spaced_position(self, idx):

    pos = spaces = 0
    if (idx < 0):
        idx = (len(self) + idx)
    if (not (0 <= idx < len(self))):
        raise IndexError('list    index    out    of    range')
    idx0 = idx
    while (idx != (-1)):
        if spacey(self.spaced[pos]):
            spaces += 1
        else:
            idx -= 1
        pos += 1
    return (idx0 + spaces)
