def swapkey(self, old_key, new_key, new_value=None):
if self.has_resolvers:<EOL><INDENT>maps = self.resolvers.maps + self.scope.maps<EOL><DEDENT>else:<EOL><INDENT>maps = self.scope.maps<EOL><DEDENT>maps.append(self.temps)<EOL>for mapping in maps:<EOL><INDENT>if old_key in mapping:<EOL><INDENT>mapping[new_key] = new_value<EOL>return<EOL><DEDENT><DEDENT>
Replace a variable name, with a potentially new value.

        Parameters
        ----------
        old_key : str
            Current variable name to replace
        new_key : str
            New variable name to replace `old_key` with
        new_value : object
            Value to be replaced along with the possible renaming