class Singleton:
def __new__(cls, *args, **kwargs):
if not hasattr( cls, '_instance'):
_instance = super().__new__(cls, *args, **kwargs)
cls._instance = _instance
return cls._instance
class Test(Singleton):
pass
网友评论