def pop(self, index=-1) -> Union[int, Expression]:
        """
        :param index:index to be popped, same as the list() class.
        :returns popped value
        :function: same as list() class but throws StackUnderflowException for popping from an empty list
        """

        try:
            return super(MachineStack, self).pop(index)
        except IndexError:
            raise StackUnderflowException("Trying to pop from an empty stack")
def pop ( self , index = - 1 ) -> Union [ int , Expression ] : try : return super ( MachineStack , self ) . pop ( index ) except IndexError : raise StackUnderflowException ( "Trying to pop from an empty stack" )
:param index:index to be popped, same as the list() class.
        :returns popped value
        :function: same as list() class but throws StackUnderflowException for popping from an empty list