def scopes_as ( self , new_scopes ) : old_scopes , self . scopes = self . scopes , new_scopes yield self . scopes = old_scopes
python change variables in outer scope
Replace my : attr : scopes for the duration of the with block .
def scopes_as(self, new_scopes):
        """Replace my :attr:`scopes` for the duration of the with block.

        My global scope is not replaced.

        Args:
            new_scopes (list of dict-likes): The new :attr:`scopes` to use.
        """
        old_scopes, self.scopes = self.scopes, new_scopes
        yield
        self.scopes = old_scopes