Skip to content

Instantly share code, notes, and snippets.

@gvx
Created December 26, 2008 10:39
Show Gist options
  • Save gvx/40035 to your computer and use it in GitHub Desktop.
Save gvx/40035 to your computer and use it in GitHub Desktop.
A function to rename variables
#By Robin Wellner (gvx)
#I hereby waive copyright and related or neighboring rights to this work
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/>
def rename(oldname, newname, scope):
scope[newname] = scope[oldname]
if hasattr(scope[newname], '__name__'): scope[newname].__name__ = newname
del scope[oldname]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment