class UnsafeString: def __init__(self, str): self._str = str self._sanitized = None def __str__(self): return self.sanitize() def unsafe(self): return self._str def sanitize(self): if self._sanitized != None: return self._sanitized else: self._sanitized = sanitize(self._sanitized) return self._sanitized