def __setitem__(self, index, value):
        """Set an item at a given position."""
        if isinstance(index, slice):
            return super(Collection, self).__setitem__(index,
                                                       self.__class__(value))
        else:
            return super(Collection, self).__setitem__(
                index, self._ensure_value_is_valid(value))
def __setitem__ ( self , index , value ) : if isinstance ( index , slice ) : return super ( Collection , self ) . __setitem__ ( index , self . __class__ ( value ) ) else : return super ( Collection , self ) . __setitem__ ( index , self . _ensure_value_is_valid ( value ) )
Set an item at a given position.