def __enter__(self):
        """Show all attributes temporarily as global variables."""
        self._entries += 1
        if self._entries == 1:
            callers = []
            depth = 0
            try:
                while 1:
                    callers.append(_getframe(depth + 1).f_locals)
                    depth += 1
                    if _getframe(depth).f_code.co_name == '<module>': raise
            except:
                pass
            callers.append(_getframe(depth).f_globals)
            callers.reverse()
            self._callers = callers
            self._backups = [s.copy() for s in self._callers]
            self._callers[0].update(self.__dict__)
Show all attributes temporarily as global variables.
recipes/Python/577372_Attributes_local_variables_inside/recipe-577372.py