Created
May 17, 2023 03:38
-
-
Save JustinStitt/8c0615188093c8dd91d0ffd85997029b to your computer and use it in GitHub Desktop.
Singleton pattern in 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 DB: | |
_instance = None | |
def __new__(cls): | |
if not cls._instance: | |
cls._instance = super(DB, cls).__new__(cls) | |
return cls._instance | |
def __init__(self): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment