Singleton is one of the design patterns which gives a way of access to its multiple objects of the class# code example
Example 1: singleton pattern
class Singleton:
__instance = None
def __new__(cls, *args):
if cls.__instance is None:
cls.__instance = object.__new__(cls, *args)
return cls.__instance
Example 2: singleton pattern
class Singleton(object):
__instance = None
def __new__(cls, *args):
if cls.__instance is None:
cls.__instance = object.__new__(cls, *args)
return cls.__instance