class Singleton:
__instance = None
def __new__(cls, *args):
if cls.__instance is None:
cls.__instance = object.__new__(cls, *args)
return cls.__instance
原文链接:
https://medium.com/techtofreedom/3-levels-of-understanding-the-singleton-pattern-in-python-4bf429a10438?sk=392159676dc87218a1b7b8c6830bc277