| f | class NegExt: | f | class NegExt: | 
            |  |  |  |  | 
            |  | def __neg__(self): |  | def __neg__(self): | 
            |  | base_class = self.__class__.mro()[2] |  | base_class = self.__class__.mro()[2] | 
            |  | try: |  | try: | 
            |  | result = base_class.__neg__(self) |  | result = base_class.__neg__(self) | 
            |  | except (TypeError, AttributeError): |  | except (TypeError, AttributeError): | 
            |  | try: |  | try: | 
            |  | result = self[1:-1] |  | result = self[1:-1] | 
            | n | except (TypeError, AttributeError, KeyError): | n | except (TypeError, IndexError, KeyError): | 
            |  | result = self |  | result = self | 
            | t | return type(self)(result) | t | return self.__class__(result) |