Skip to content

Instantly share code, notes, and snippets.

@iorlas
Created January 20, 2011 17:31
class Singleton(object):
__instance = None
def __new__(cls, *a, **kva):
'''
Singleton getter/creator
@return: Class instance
'''
if cls.__instance is None:
cls.__instance = object.__new__(cls)
else:
cls.__init__ = lambda x: None
return cls.__instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment