Get the result of :meth:`doprint` from the internal cache

def _get_from_cache(self, expr):
        """Get the result of :meth:`doprint` from the internal cache"""
        # The reason method this is separated out from `doprint` is that
        # printers that use identation, e.g. IndentedSReprPrinter, need to
        # override how caching is handled, applying variable indentation even
        # for cached results
        try:
            is_cached = expr in self.cache
        except TypeError:
            # expr is unhashable
            is_cached = False
        if is_cached:
            return True, self.cache[expr]
        else:
            return False,  None