Skip to content

Instantly share code, notes, and snippets.

@geblanco
Created December 13, 2022 14:49
Show Gist options
  • Save geblanco/2cea2c2e40d3366bf732ea73d7fdffa3 to your computer and use it in GitHub Desktop.
Save geblanco/2cea2c2e40d3366bf732ea73d7fdffa3 to your computer and use it in GitHub Desktop.
Singleton class
# 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