Created
January 20, 2011 17:31
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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