# Here’s an example of coding a Singleton class with a .__new__() method
# that allows the creation of only one instance at a time

# .__new__() checks the existence of previous instances cached on a
# class attribute


class Singleton(object):
    _instance = None

    def __new__(cls, *args, **kwargs):
        if cls._instance is None:
            cls._instance = super().__new__(cls)
        return cls._instance


first = Singleton()
second = Singleton()
print(first is second)