Created
December 13, 2022 14:49
-
-
Save geblanco/2cea2c2e40d3366bf732ea73d7fdffa3 to your computer and use it in GitHub Desktop.
Singleton class
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
# coding=utf-8 | |
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