-
-
Save kunimi/8afd48b33e7a2b6f0fd0 to your computer and use it in GitHub Desktop.
Singleton Python
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): | |
def __new__(cls): | |
if not hasattr(cls, 'instance'): | |
cls.instance = super(Singleton, cls).__new__(cls) | |
return cls.instance |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment