<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pop(self, index=None):
 """ Removes and returns the item at @index or from the end of the list -> item at @index """

        if index is None:
            return self._loads(self._client.rpop(self.key_prefix))
        elif index == 0:
            return self._loads(self._client.lpop(self.key_prefix))
        else:
            _uuid = gen_rand_str(16, 24)
            r = self[index]
            self[index] = _uuid
            self.remove(_uuid)
            return r