class Singleton(object):
    _instance = None

def __new__(cls, *args, **kwargs):
    if Singleton._instance is None:
        Singleton._instance = object.__new__(cls, *args, **kwargs)
return Singleton._instance
if __name__ == '__main__':
    s1 = Singleton()
s2 = Singleton()
print('s1 is s2:', s1 is s2)
print('id(s1):', id(s1))
print('id(s2):', id(s2))
Implementation of NoneType, Reasons and Details