def formatted(self, func):
        """Return the string with non-literal parts formatted.

        Args:
            func (callable): Callable that translates a string into a
                formatted string.

        Returns:
            `EscapedString` object.
        """
        other = EscapedString.__new__(EscapedString)
        other.strings = []

        for is_literal, value in self.strings:
            if not is_literal:
                value = func(value)
            other.strings.append((is_literal, value))
        return other
def formatted ( self , func ) : other = EscapedString . __new__ ( EscapedString ) other . strings = [ ] for is_literal , value in self . strings : if not is_literal : value = func ( value ) other . strings . append ( ( is_literal , value ) ) return other
Return the string with non-literal parts formatted.

        Args:
            func (callable): Callable that translates a string into a
                formatted string.

        Returns:
            `EscapedString` object.