Skip to content

Instantly share code, notes, and snippets.

@dredozubov
Created March 5, 2013 11:15
Show Gist options
  • Save dredozubov/5089611 to your computer and use it in GitHub Desktop.
Save dredozubov/5089611 to your computer and use it in GitHub Desktop.
singleton decorator
def singleton(cls):
instances = {}
def getinstance():
if cls not in instances:
instances[cls] = cls()
return instances[cls]
return getinstance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment