import functools
def Singleton(cls):

    # TODO: make the true singleton

    instance = cls()
    instance.__call__ = lambda: instance
    return instance


if __name__ == "__main__":
    @Singleton
    class TestClass:
        def __init__(self):
            print ("constructor called")

    print ("starting")

    a = TestClass()
    b = TestClass()
    #assert isinstance(a, TestClass), "Class is not instance of TestClass"
    assert a == b, "Classes are different"

488f6bcc9da1f5e5a178701ee2d9ce9e1dd53bf1
<mask token>

<mask token>


def Singleton(cls):
    instance = cls()
    instance.__call__ = lambda : instance
    return instance


<mask token>

<mask token>


def Singleton(cls):
    instance = cls()
    instance.__call__ = lambda : instance
    return instance


if __name__ == '__main__':


    @Singleton
    class TestClass:

        def __init__(self):
            print('constructor called')
    print('starting')
    a = TestClass()
    b = TestClass()
    assert a == b, 'Classes are different'

import functools


def Singleton(cls):
    instance = cls()
    instance.__call__ = lambda : instance
    return instance


if __name__ == '__main__':


    @Singleton
    class TestClass:

        def __init__(self):
            print('constructor called')
    print('starting')
    a = TestClass()
    b = TestClass()
    assert a == b, 'Classes are different'

import functools
def Singleton(cls):

    # TODO: make the true singleton

    instance = cls()
    instance.__call__ = lambda: instance
    return instance


if __name__ == "__main__":
    @Singleton
    class TestClass:
        def __init__(self):
            print ("constructor called")

    print ("starting")

    a = TestClass()
    b = TestClass()
    #assert isinstance(a, TestClass), "Class is not instance of TestClass"
    assert a == b, "Classes are different"
