Skip to content

Instantly share code, notes, and snippets.

@tehmaze
Created January 9, 2011 21:57
Show Gist options
  • Save tehmaze/772075 to your computer and use it in GitHub Desktop.
Save tehmaze/772075 to your computer and use it in GitHub Desktop.
Singleton Class decorator
def singleton(cls):
instances = {}
def instance():
if cls not in instances:
instances[cls] = cls()
return instances[cls]
return instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment